let () =
  let n = read_line () in
  print_endline @@
  if
    ( = ) 0 @@
    Fun.flip ( mod ) 9 @@
    Array.fold_left (fun acc c -> acc + Char.code c - Char.code '0') 0 @@
    Array.init (String.length n) (String.get n)
  then "Yes"
  else "No"
