// GetData.java: fetch the next int from input.
import java.io.*;
public class GetData {
   Reader in; // reader for reading input data

   public GetData() {
      in = new InputStreamReader(System.in); // create reader
   }

   private char getNextChar() {
      char ch = ' '; // to make compiler happy
      try {
         ch = (char)in.read();
      }
      catch (IOException e) 
      {
         System.out.println("Error reading character");
         System.exit(1);
      }
      return ch;
   }

   public int getNextInt() {
      String s = "";
      char ch;
      ch = getNextChar();
      // skip over initial blanks and newlines
      while (ch == ' ' || ch == '\n')
         ch = getNextChar();
      // read optional + or - sign
      if (ch == '+' || ch == '-') {
         s += ch;
         ch = getNextChar();
      }
      // read digits, store in s   
      while (Character.isDigit(ch)) {
         s += ch;
         ch = getNextChar();
      }
      return Integer.parseInt(s);
   }
}