Imports System

Module Program
    Sub Main(args As String())

        Dim N As String = Console.ReadLine()

        Dim wa As Integer = 0
        For i As Integer = 1 To Len(N)
            wa += Integer.Parse(Mid(N, i, 1))
        Next

        Dim ans As String = ""
        If wa Mod 9 = 0 Then
            ans = "Yes"
        Else
            ans = "No"
        End If

        Console.WriteLine(ans)

    End Sub
End Module
