#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string N;
  cin >> N;
  long long size = N.size();
  long long ans = 0;
  for (long long i = 0; i < long long(size); i++) {
    ans += N[i] - '0';
  }
  if (ans % 9 == 0) {
    cout << "Yes";
    return 0;
  }
  cout << "No" << endl;
  return 0;
}
