import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	}

} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	}

} Main public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	} main {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s=br.readLine(); s br.readLine() br.readLine br long sum=0; sum 0 for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48; int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i sum+=s.charAt(i)-48; sum+=s.charAt(i)-48 sum s.charAt(i)-48 s.charAt(i) s.charAt s i 48 System.out.println(sum%9==0?"Yes":"No") System.out.println System.out System System.out sum%9==0?"Yes":"No" sum%9==0 sum%9 sum 9 0 "Yes" "No" String[] args args public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	}

} public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	}

} Main
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		long sum=0;
		for(int i=0; i<s.length(); i++) sum+=s.charAt(i)-48;
		System.out.println(sum%9==0?"Yes":"No");
	}

}