#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string n;
  cin >> n;
  long long sum = 0;
  for (long long i = 0; i <= (int)(n).size() - 1; i++) {
    sum += (n[i] - '0');
  }
  if (sum % 9 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
