import java.util.Scanner;

public class Main {

    private static final int NINE＿VAL = 9;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    private static final int NINE＿VAL = 9;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    }
} Main private static final int NINE＿VAL = 9; NINE＿VAL 9 public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    } main {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final String indexStr = sc.next(); indexStr sc.next() sc.next sc String[] Array = indexStr.split(""); Array indexStr.split("") indexStr.split indexStr "" int iTotalVal = 0; iTotalVal 0 for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        } String i Array {
            iTotalVal += Integer.parseInt(i);
        } {
            iTotalVal += Integer.parseInt(i);
        } iTotalVal += Integer.parseInt(i) iTotalVal Integer.parseInt(i) Integer.parseInt Integer i String outputVal = ""; outputVal "" if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        } 0 == (iTotalVal % NINE＿VAL) 0 (iTotalVal % NINE＿VAL) iTotalVal NINE＿VAL {
            outputVal = "Yes";
        } outputVal = "Yes" outputVal "Yes" {
            outputVal = "No";
        } outputVal = "No" outputVal "No" System.out.print(outputVal) System.out.print System.out System System.out outputVal String[] args args public class Main {

    private static final int NINE＿VAL = 9;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    }
} public class Main {

    private static final int NINE＿VAL = 9;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    }
} Main
import java.util.Scanner;

public class Main {

    private static final int NINE＿VAL = 9;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final String indexStr = sc.next();
        String[] Array = indexStr.split("");
        int iTotalVal = 0;
        for (String i : Array) {
            iTotalVal += Integer.parseInt(i);
        }

        String outputVal = "";
        // 入力された文字の総数が9の倍数か？
        if (0 == (iTotalVal % NINE＿VAL)) {
            outputVal = "Yes";
        } else {
            outputVal = "No";
        }
        System.out.print(outputVal);
    }
}
