import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

        if(sum%9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args)
    {
        Scanner inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

        if(sum%9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main public static void main(String[] args)
    {
        Scanner inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

        if(sum%9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    } main {
        Scanner inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

        if(sum%9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    } Scanner inputs = new Scanner(System.in); inputs new Scanner(System.in) String n = inputs.next(); n inputs.next() inputs.next inputs int sum = 0; sum 0 for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch); char ch n.toCharArray() n.toCharArray n sum += Character.getNumericValue(ch); sum += Character.getNumericValue(ch) sum Character.getNumericValue(ch) Character.getNumericValue Character ch 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 System.out System System.out "Yes" 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 inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

        if(sum%9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} public class Main {
    public static void main(String[] args)
    {
        Scanner inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

        if(sum%9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner inputs = new Scanner(System.in);
        String n = inputs.next();
        int sum = 0;
        for(char ch: n.toCharArray())
            sum += Character.getNumericValue(ch);

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