#include main(){ long long n; std::cin >> n; std::cout <<(n % 3 ? "NO" : "YES") << std::endl; }