import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc int sum = 0; sum 0 for(char each : a.toCharArray()){
            sum += each - '0';
        } char each a.toCharArray() a.toCharArray a {
            sum += each - '0';
        } {
            sum += each - '0';
        } sum += each - '0' sum each - '0' each '0' String res = sum % 9 == 0 ? "Yes" : "No"; res sum % 9 == 0 ? "Yes" : "No" sum % 9 == 0 sum % 9 sum 9 0 "Yes" "No" System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int sum = 0;

        for(char each : a.toCharArray()){
            sum += each - '0';
        }
        String res = sum % 9 == 0 ? "Yes" : "No";
        System.out.println(res);
    }
}