#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n = 0, result = 0;
  cin >> s;
  for (int i = 0; i < (int)(s.size()); i++) {
    n = (int)(s[i]) - '0';
    result = (result + n) % 9;
  }
  if (result == 0) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}
