import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    }
    public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    }
    public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String result = isTrue(s)%9 == 0? "Yes":"No"; result isTrue(s)%9 == 0? "Yes":"No" isTrue(s)%9 == 0 isTrue(s)%9 isTrue(s) isTrue s 9 0 "Yes" "No" System.out.println(result) System.out.println System.out System System.out result String[] args args public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    } isTrue {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    } int count = 0; count 0 for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            count += s.charAt(i)-'0';
        } {
            count += s.charAt(i)-'0';
        } count += s.charAt(i)-'0' count s.charAt(i)-'0' s.charAt(i) s.charAt s i '0' return count; count String s s public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    }
    public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    }
    public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    }
    public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    }
}