/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%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) throws java.lang.Exception
	{
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	} main {
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String str=scan.next(); str scan.next() scan.next scan long c=0; c 0 for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
	        c+=(str.charAt(i)-'0');
	    } {
	        c+=(str.charAt(i)-'0');
	    } c+=(str.charAt(i)-'0') c (str.charAt(i)-'0') str.charAt(i) str.charAt str i '0' if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No"); c%9 == 0 c%9 c 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) throws java.lang.Exception
	{
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	}
} Main
/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner scan=new Scanner(System.in);
	    String str=scan.next();
	    long c=0;
	    for(int i=0;i<str.length();i++)
	    {
	        c+=(str.charAt(i)-'0');
	    }
	    if(c%9 == 0)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	}
}
