#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int sum = 0;
    for (auto c:s) {
        sum += c - '0';
    }
    cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
}