#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n && n){ if(n % 3 == 2) cout << "NO\n"; else cout << "YES\n"; } return 0; }