BufferedReader reader =new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(reader.readLine());

Read more of this post