#include <iostream>
#include <string>
using namespace std;

int main() {
    string n; cin >> n;

    int sum = 0;
    for (auto c : n) sum += c - '0';

    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

