a = gets.to_i if (a%3 == 0) puts 'YES' else puts 'NO' end