
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim max As Int64
    Dim n, k, x, t As Int64
    Sub Main()
        Dim n2 As String
        n2 = ReadLine()
        Dim ncc() As Char = n2.ToCharArray
        Dim nc(ncc.Length - 1) As String
        Dim ni(ncc.Length - 1) As Integer
        Dim wa As Integer
        For i = 0 To nc.Length - 1
            nc(i) = ncc(i)
        Next
        For i = 0 To nc.Length - 1
            ni(i) = nc(i)
            wa += ni(i)
            wa = wa Mod 9
        Next
        If wa = 0 Then
            WriteLine("Yes")
        Else
            WriteLine("No")
        End If
        'WriteLine(ans)
    End Sub
End Module
