#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	string n;
	cin>>n;
	ll ans=0;
	for(auto ch:n)
	{
		ans+=ch-'0';
	}	
	if(ans%9==0)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}

