require 'prime' n = gets.to_i a = Prime.prime_division(n).to_a.map{|x|[x[0]] * x[1]}.flatten b = [1] * 3 (a.size - 1).downto(0){|i| b[0] *= a[i] b.sort! } tmin = b.map{|x|x - 1}.inject(:+) tmax = n - 1 puts "#{tmin} #{tmax}"