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