#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  char s[200000];
  cin >> s;
  int len = strlen(s), ans = 0;
  for (int i = 0; i < len; i++) {
    ans += s[i] - '0';
  }
  if (ans % 9 == 0)
    cout << "Yes";
  else
    cout << "No";
}
