require'prime' d=0,*[-1]*n=gets.to_i Prime.each(999){|p|n.downto(p){|i|d[i]=[d[i],d[i-p]+1].max}} p d[n]