/* package whatever; // 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
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 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
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No");
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No");
	} main {
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No");
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String n = scanner.next(); n scanner.next() scanner.next scanner int sum = 0; sum 0 int i = n.length() - 1; i n.length() - 1 n.length() n.length n 1 while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    } i >=0 i 0 {
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    } int num = n.charAt(i) - '0'; num n.charAt(i) - '0' n.charAt(i) n.charAt n i '0' sum = (sum + num) % 9 sum (sum + num) % 9 (sum + num) sum num 9 i-- i if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No"); sum == 0 sum 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
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No");
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No");
	}
} Main
/* package whatever; // 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
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    String n = scanner.next();
	    
	    int sum = 0;
	    int i = n.length() - 1;
	    while(i >=0){
	    	int num = n.charAt(i) - '0';
	    	sum = (sum + num) % 9;
	    	i--;
	    }
	    
	    if(sum == 0)
	      System.out.println("Yes");
		
		else
			System.out.println("No");
	}
}