import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





}
} import java.io.BufferedReader; BufferedReader java.io import java.io.*; io.* java import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Collections; Collections java.util import java.util.Arrays; Arrays java.util public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





}
} Main public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





} main {
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





} final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final List<Long> list = new ArrayList<>(); list new ArrayList<>() String n = sc.next(); n sc.next() sc.next sc char[] work = new char[n.length()]; work new char[n.length()] n.length() n.length n int num = 0; num 0 for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            } int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            } {
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            } work[i] = n.charAt(i) work[i] work i n.charAt(i) n.charAt n i for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    } int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
        num += Character.getNumericValue(work[i]);
    } {
        num += Character.getNumericValue(work[i]);
    } num += Character.getNumericValue(work[i]) num Character.getNumericValue(work[i]) Character.getNumericValue Character work[i] work i if(num % 9 == 0){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    } num % 9 == 0 num % 9 num 9 0 {
        System.out.println("Yes");
    } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
        System.out.println("No");
    } System.out.println("No") System.out.println System.out System System.out "No" final String[] args args public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





}
} public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





}
} Main
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Long> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String n = sc.next();
    char[] work = new char[n.length()];
    int num = 0;

    for(int i = 0; i < n.length(); i++){
            work[i] = n.charAt(i);

            //切り出した文字列を一文字ずつ出力
            //System.out.println(work[i]);
            }

    for(int i = 0; i < n.length(); i++){
        num += Character.getNumericValue(work[i]);
    }
    //System.out.println(num);

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





}
}