import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.math.BigInteger; BigInteger java.math import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    }
} Main public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    } main {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    } InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); reader new InputStreamReader(System.in, StandardCharsets.UTF_8) BufferedReader in = new BufferedReader(reader); in new BufferedReader(reader) String[] str = in.readLine().split(""); str in.readLine().split("") in.readLine().split in.readLine() in.readLine in "" double num = 0; num 0 double res = 0; res 0 for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        } int i=0; int i=0; i 0 i < str.length i str.length str str.length i++ i++ i {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        } {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        } num = num*10 + Integer.parseInt(str[i]) num num*10 + Integer.parseInt(str[i]) num*10 num 10 Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            } i % 5 == 0 i % 5 i 5 0 {
        		res += num % 9;
        		num = 0;
        	} res += num % 9 res num % 9 num 9 num = 0 num 0 if(i == str.length-1){
        		res += num % 9;
            } i == str.length-1 i str.length-1 str.length str str.length 1 {
        		res += num % 9;
            } res += num % 9 res num % 9 num 9 if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        } res % 9 == 0 res % 9 res 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" String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    }
} public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split("");
        double num = 0;
        double res = 0;

        for(int i=0; i < str.length; i++) {
        	num = num*10 + Integer.parseInt(str[i]);
        	if(i % 5 == 0 ) {
        		res += num % 9;
        		num = 0;
        	}
            else if(i == str.length-1){
        		res += num % 9;
            }
        }
        if(res % 9 == 0) {
            System.out.println("Yes");

        }else {
            System.out.println("No");
        }

    }
}