#include <iostream>using namespace std;
int main() { long long int x; while(cin>>x){ if(x%3==0) cout<<"YES"<<endl; else cout<<"NO"<<endl; }}