import java.util.Scanner;

public class Main {
    public boolean isMultipleOfNine(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public boolean isMultipleOfNine(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    }
} Main public boolean isMultipleOfNine(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    } isMultipleOfNine {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    } int sum = 0; sum 0 for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        } int i = 0; int i = 0; i 0 i < num.length() i num.length() num.length num i++ i++ i {
            int digit = num.charAt(i) - '0';
            sum += digit;
        } {
            int digit = num.charAt(i) - '0';
            sum += digit;
        } int digit = num.charAt(i) - '0'; digit num.charAt(i) - '0' num.charAt(i) num.charAt num i '0' sum += digit sum digit if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        } num.length() < 10 num.length() num.length num 10 {
            return sum % 9 == 0;
        } return sum % 9 == 0; sum % 9 == 0 sum % 9 sum 9 0 {
            return isMultipleOfNine(String.valueOf(sum));
        } return isMultipleOfNine(String.valueOf(sum)); isMultipleOfNine(String.valueOf(sum)) isMultipleOfNine String.valueOf(sum) String.valueOf String sum String num num public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    } main {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    } Main solution = new Main(); solution new Main() Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String n = scanner.next(); n scanner.next() scanner.next scanner boolean answer = solution.isMultipleOfNine(n); answer solution.isMultipleOfNine(n) solution.isMultipleOfNine solution n if (answer) System.out.println("Yes");
        else System.out.println("No"); answer System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {
    public boolean isMultipleOfNine(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    }
} public class Main {
    public boolean isMultipleOfNine(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    }
} Main
import java.util.Scanner;

public class Main {
    public boolean isMultipleOfNine(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            int digit = num.charAt(i) - '0';
            sum += digit;
        }

        if (num.length() < 10) {
            return sum % 9 == 0;
        } else {
            return isMultipleOfNine(String.valueOf(sum));
        }
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();

        boolean answer = solution.isMultipleOfNine(n);
        if (answer) System.out.println("Yes");
        else System.out.println("No");
    }
}