import java.util.*;

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

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