#include <bits/stdc++.h>
int main() {
  char c;
  long long sum = 0, ans;
  while (EOF != (c = getchar())) {
    sum += c - '0';
  }
  ans = sum % 9;
  if (ans == 0) {
    printf("No");
  } else {
    printf("Yes");
  }
  return 0;
}
