

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    } main {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) String str = s.next(); str s.next() s.next s int sum = 0; sum 0 for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        } int j=0; int j=0; j 0 j<str.length() j str.length() str.length str j++ j++ j {
            sum+=Character.getNumericValue(str.charAt(j));
        } {
            sum+=Character.getNumericValue(str.charAt(j));
        } sum+=Character.getNumericValue(str.charAt(j)) sum Character.getNumericValue(str.charAt(j)) Character.getNumericValue Character str.charAt(j) str.charAt str j 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)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}