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