let findSumOfDigits s =
  let l = List.of_seq (String.to_seq s) in
  List.fold_left
    (fun acc c ->
      acc + ((Char.code c) - 48))
    0
    l

let main () =
  let line = read_line () in
  let r = (findSumOfDigits line) mod 9 in
  let ans = if r = 0
            then
              "Yes"
            else
              "No" in
  (
    print_string ans;
    print_newline ()
  )

let _ = main ()
