#include <bits/stdc++.h>
using namespace std;
int main() {
  int cow = 0;
  string a;
  cin >> a;
  for (int i = 0; a[i]; i++) cow += a[i];
  if (cow % 9)
    cout << "No";
  else
    cout << "Yes";
}
