import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

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

	private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

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

	private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

		if(sum % 9 != 0)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		}
	} main {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

		if(sum % 9 != 0)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc char[] list = str.toCharArray(); list str.toCharArray() str.toCharArray str int[] intArray = convertIntArray(list); intArray convertIntArray(list) convertIntArray list int sum = 0; sum 0 for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		} int i = 0; int i = 0; i 0 i < intArray.length i intArray.length intArray intArray.length i++ i++ i {
			sum += intArray[i];
		} {
			sum += intArray[i];
		} sum += intArray[i] sum intArray[i] intArray i if(sum % 9 != 0)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		} sum % 9 != 0 sum % 9 sum 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 private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	} convertIntArray {
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	} int[] intArray = new int[array.length]; intArray new int[array.length] array.length array array.length int index = 0; index 0 for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		} int i = 0; int i = 0; i 0 i < array.length i array.length array array.length i++ i++ i {
			intArray[i] = Character.getNumericValue(array[i]);
		} {
			intArray[i] = Character.getNumericValue(array[i]);
		} intArray[i] = Character.getNumericValue(array[i]) intArray[i] intArray i Character.getNumericValue(array[i]) Character.getNumericValue Character array[i] array i return intArray; intArray char[] array array public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

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

	private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

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

	private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

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

	private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	}
}
