PROGRAM B
  IMPLICIT NONE
  CHARACTER(len=200000) :: S
  CHARACTER,dimension(1:200000):: l
  INTEGER :: i,sum=0,tmp=0

  READ *, S
  Do i=1,200000
  l(i) = S(i:i)
  IF(l(i)==" ")l(i)="0"
  read(l(i),*) tmp
  sum=sum+tmp
  End Do

  IF(mod(sum,9)==0)THEN
    PRINT *, 'Yes'
  ELSE
    PRINT *, 'No'
  END IF
END PROGRAM B
