# frozen_string_literal: true def solve (A % 3).zero? ? 'YES' : 'NO' end A = gets.to_i puts solve