while input = gets
  n = input.chomp.to_i;
  if n>=1 && n<=999999
    for i in 2..n-1 do
      if n % i != 0
        if i == n-1
          puts n;
        end
        next;
      else
        break;
      end
    end
  else
    break;
  end
end

