open Printf
open Scanf

let solve n =
  let l = String.length n in
  let rec loop r i =
    if i = l then r
    else let t = (Char.code n.[i] - 48 + r) mod 9
         in loop t (i + 1) in
  let r = loop 0 0 in
  if r = 0 then "Yes" else "No"

let () =
  scanf "%s " solve |> printf "%s\n"
