

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    }
} Main public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    } main {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    } final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) final String line = in.nextLine(); line in.nextLine() in.nextLine in int digitsSum = 0; digitsSum 0 for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        } char c line.toCharArray() line.toCharArray line {
            digitsSum = (digitsSum + c - '0') % 9;
        } {
            digitsSum = (digitsSum + c - '0') % 9;
        } digitsSum = (digitsSum + c - '0') % 9 digitsSum (digitsSum + c - '0') % 9 (digitsSum + c - '0') digitsSum + c digitsSum c '0' 9 System.out.println(digitsSum == 0 ? "Yes" : "No") System.out.println System.out System System.out digitsSum == 0 ? "Yes" : "No" digitsSum == 0 digitsSum 0 "Yes" "No" String[] args args public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    }
} public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    }
} Main


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    }
}
