A = gets.to_i if A % 3 == 0 puts 'YES' else puts 'NO' end