import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.stream.IntStream;

public class Main {

    // Multiple of 9
    public static String multipleOfNine(String Number){
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    }

    public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Iterator; Iterator java.util import java.util.stream.IntStream; IntStream java.util.stream public class Main {

    // Multiple of 9
    public static String multipleOfNine(String Number){
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    }

    public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} Main // Multiple of 9
    public static String multipleOfNine(String Number){
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    } multipleOfNine {
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    } int sumOfDigits = 0; sumOfDigits 0 String[] digits2 = Number.split("(?<=.)"); digits2 Number.split("(?<=.)") Number.split Number "(?<=.)" for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        } int i = 0; int i = 0; i 0 i <digits2.length i digits2.length digits2 digits2.length i++ i++ i {
            sumOfDigits += Integer.parseInt(digits2[i]);
        } {
            sumOfDigits += Integer.parseInt(digits2[i]);
        } sumOfDigits += Integer.parseInt(digits2[i]) sumOfDigits Integer.parseInt(digits2[i]) Integer.parseInt Integer digits2[i] digits2 i return sumOfDigits%9 == 0 ? "Yes": "No"; sumOfDigits%9 == 0 ? "Yes": "No" sumOfDigits%9 == 0 sumOfDigits%9 sumOfDigits 9 0 "Yes" "No" String Number Number public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    } main {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    } InputStreamReader in = new InputStreamReader(System.in); in new InputStreamReader(System.in) BufferedReader bufferedReader = new BufferedReader(in); bufferedReader new BufferedReader(in) try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } String input = bufferedReader.readLine(); input bufferedReader.readLine() bufferedReader.readLine bufferedReader String[] inputsArrays = input.split(" "); inputsArrays input.split(" ") input.split input " " String N = inputsArrays[0]; N inputsArrays[0] inputsArrays 0 System.out.println(multipleOfNine(N)) System.out.println System.out System System.out multipleOfNine(N) multipleOfNine N String[] args args public class Main {

    // Multiple of 9
    public static String multipleOfNine(String Number){
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    }

    public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} public class Main {

    // Multiple of 9
    public static String multipleOfNine(String Number){
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    }

    public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.stream.IntStream;

public class Main {

    // Multiple of 9
    public static String multipleOfNine(String Number){
        int sumOfDigits = 0;
        String[] digits2 = Number.split("(?<=.)");
        for (int i = 0; i <digits2.length ; i++) {
            sumOfDigits += Integer.parseInt(digits2[i]);
        }
        return sumOfDigits%9 == 0 ? "Yes": "No";
    }

    public static void main(String[] args) {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(in);
        try {
            String input = bufferedReader.readLine();
            String[] inputsArrays = input.split(" ");
            String N = inputsArrays[0];
            System.out.println(multipleOfNine(N));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}