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

class Main
{
  static boolean checkDivofNine(String str)
  {
	int n=str.length();
    int res=0;
    for(int i=0;i<n;i++)
    {
		res+=(str.charAt(i)-'0');
    }
      	return(res%9==0);
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
   	String str=sc.next();
    if(checkDivofNine(str))
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java class Main
{
  static boolean checkDivofNine(String str)
  {
	int n=str.length();
    int res=0;
    for(int i=0;i<n;i++)
    {
		res+=(str.charAt(i)-'0');
    }
      	return(res%9==0);
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
   	String str=sc.next();
    if(checkDivofNine(str))
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  }
} Main static boolean checkDivofNine(String str)
  {
	int n=str.length();
    int res=0;
    for(int i=0;i<n;i++)
    {
		res+=(str.charAt(i)-'0');
    }
      	return(res%9==0);
  } checkDivofNine {
	int n=str.length();
    int res=0;
    for(int i=0;i<n;i++)
    {
		res+=(str.charAt(i)-'0');
    }
      	return(res%9==0);
  } int n=str.length(); n str.length() str.length str int res=0; res 0 for(int i=0;i<n;i++)
    {
		res+=(str.charAt(i)-'0');
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
		res+=(str.charAt(i)-'0');
    } {
		res+=(str.charAt(i)-'0');
    } res+=(str.charAt(i)-'0') res (str.charAt(i)-'0') str.charAt(i) str.charAt str i '0' return(res%9==0); (res%9==0) res%9 res 9 0 String str str public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
   	String str=sc.next();
    if(checkDivofNine(str))
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  } main {
    Scanner sc=new Scanner(System.in);
   	String str=sc.next();
    if(checkDivofNine(str))
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String str=sc.next(); str sc.next() sc.next sc if(checkDivofNine(str))
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    } checkDivofNine(str) checkDivofNine str {
      System.out.print("Yes");
    } System.out.print("Yes") System.out.print System.out System System.out "Yes" {
      System.out.print("No");
    } System.out.print("No") System.out.print System.out System System.out "No" String[] args args
import java.io.*;
import java.util.*;

class Main
{
  static boolean checkDivofNine(String str)
  {
	int n=str.length();
    int res=0;
    for(int i=0;i<n;i++)
    {
		res+=(str.charAt(i)-'0');
    }
      	return(res%9==0);
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
   	String str=sc.next();
    if(checkDivofNine(str))
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  }
}