require 'prime' n,l=gets.split.map(&:to_i) r=0 Prime.each{|e| l0=e*(n-1) x=l-l0+1 break if x<=0 r+=x } p r