let () = Scanf.scanf "%s" @@ fun s ->
  let n = String.length s in
  let sum = List.fold_left (fun acm i -> 
    let num = Char.code s.[i] - 48 in acm + num)
    0 @@ List.init n Fun.id in
  let ans = if sum mod 9 = 0 then "Yes\n" else "No\n" in
  Printf.printf "%s" ans