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);
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz