#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[2000000];
  int i = 0;
  scanf("%s", a);
  int len = strlen(a);
  int sum = 0;
  for (int j = 0; j <= len; j++) {
    sum += a[j] - 48;
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
