/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      }
   } import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      }
   } Main public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      } main {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      } BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); infile new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(infile.readLine()); st new StringTokenizer(infile.readLine()) String input = st.nextToken(); input st.nextToken() st.nextToken st int sum = 0; sum 0 for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0'); int i=0; int i=0; i 0 i < input.length() i input.length() input.length input i++ i++ i sum += (input.charAt(i)-'0'); sum += (input.charAt(i)-'0') sum (input.charAt(i)-'0') input.charAt(i) input.charAt input i '0' String res = sum%9 == 0 ? "Yes" : "No"; res sum%9 == 0 ? "Yes" : "No" sum%9 == 0 sum%9 sum 9 0 "Yes" "No" System.out.println(res) System.out.println System.out System System.out res String hi[] hi public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      }
   } public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      }
   } Main
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int sum = 0;
         for(int i=0; i < input.length(); i++)
            sum += (input.charAt(i)-'0');
         String res = sum%9 == 0 ? "Yes" : "No";
         System.out.println(res);
      }
   }