import java.util.*;
public class Main{   
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
  String  a = scanner.next();
        char[] chars = a.toCharArray();
        int sum =0;
        for (char aChar : chars) {
            sum+= aChar-'0';
        }

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

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

        if(sum%9==0)
        {
            System.out.println("Yes");
        }else
        {
            System.out.println("No");
        }
    
    } main {
        Scanner scanner = new Scanner(System.in);
  String  a = scanner.next();
        char[] chars = a.toCharArray();
        int sum =0;
        for (char aChar : chars) {
            sum+= aChar-'0';
        }

        if(sum%9==0)
        {
            System.out.println("Yes");
        }else
        {
            System.out.println("No");
        }
    
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String  a = scanner.next(); a scanner.next() scanner.next scanner char[] chars = a.toCharArray(); chars a.toCharArray() a.toCharArray a int sum =0; sum 0 for (char aChar : chars) {
            sum+= aChar-'0';
        } char aChar chars {
            sum+= aChar-'0';
        } {
            sum+= aChar-'0';
        } sum+= aChar-'0' sum aChar-'0' aChar '0' if(sum%9==0)
        {
            System.out.println("Yes");
        }else
        {
            System.out.println("No");
        } sum%9==0 sum%9 sum 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 public class Main{   
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
  String  a = scanner.next();
        char[] chars = a.toCharArray();
        int sum =0;
        for (char aChar : chars) {
            sum+= aChar-'0';
        }

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

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

        if(sum%9==0)
        {
            System.out.println("Yes");
        }else
        {
            System.out.println("No");
        }
    
    }
}