#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    ans += (int)(s[i] - '0');
  }
  if (ans % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
