let () =
  let rec solve n ans =
    if n / 10 = 0 then ans+n else solve (n / 10) (ans + (n mod 10)) in
  Scanf.scanf "%d\n" @@ fun n ->
  Printf.printf "%s\n" (if (solve n 0) mod 9 = 0 then "Yes" else "No")