#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	
	string s;
	cin>>s;
	
	int sum=0;
	
	for (auto c:s){
		sum=(sum+c-48)%9;
	}
	
	if (!sum) cout<<"Yes"; else cout<<"No";
	
}