import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
}

 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
} Main public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s = scanner.nextLine(); s scanner.nextLine() scanner.nextLine scanner int numberDigitTotal = 0; numberDigitTotal 0 for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        } {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        } numberDigitTotal += Integer.parseInt(s.substring(i,i + 1)) numberDigitTotal Integer.parseInt(s.substring(i,i + 1)) Integer.parseInt Integer s.substring(i,i + 1) s.substring s i i + 1 i 1 if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        } numberDigitTotal % 9 != 0 numberDigitTotal % 9 numberDigitTotal 9 0 {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" {
           System.out.println("Yes");
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" String args[] args public class Main {

    public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
} public class Main {

    public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
}


