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