#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long i=0,sum=0;
	while(i<s.size())
	{
		sum=sum+(s[i]-'0');
		i++;
	}
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
}
