import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    static int ctoi(char c) {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      }
    
}
 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();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    static int ctoi(char c) {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      }
    
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int ss = 0; ss 0 for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            ss += ctoi(s.charAt(i));
        } {
            ss += ctoi(s.charAt(i));
        } ss += ctoi(s.charAt(i)) ss ctoi(s.charAt(i)) ctoi s.charAt(i) s.charAt s i if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } ss%9==0 ss%9 ss 9 0 {
            System.out.println("Yes");
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" String[] args args static int ctoi(char c) {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      } ctoi {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      } if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        } '0' <= c && c <= '9' '0' <= c '0' c c <= '9' c '9' {
            return (int)(c-'0');
        } return (int)(c-'0'); (int)(c-'0') c '0' return -1; -1 1 char c c public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    static int ctoi(char c) {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      }
    
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    static int ctoi(char c) {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      }
    
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        // 文字列切り出し
        int ss = 0;
        for(int i = 0; i < s.length(); i++) {
            ss += ctoi(s.charAt(i));
        }
        if(ss%9==0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    static int ctoi(char c) {
        if ('0' <= c && c <= '9') {
            return (int)(c-'0');
        }
        return -1;
      }
    
}

