#include #include #include using namespace std; typedef long long ll; #define debug(x) cerr << "[" << #x << "] : " << x << "\n"; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll a; cin >> a; if((a - 3) % 3 == 0) cout << "YES\n"; else cout << "NO\n"; }