# frozen_string_literal: true def solve (2017 + 2017.pow(2 * 2017, M)) % M end M = gets.to_i puts solve