import java.io.PrintWriter; import java.util.Scanner; public class Main { static Scanner scan = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static int H, W; static char[][] map; static int [][] ansMap; public static void main(String[] args) { String line = scan.nextLine(); String values[] = line.split(" "); H = Integer.parseInt(values[0]); W = Integer.parseInt(values[1]);; map = new char[H][W]; ansMap = new int[H][W]; for(int i=0; i= 0 && nextX < W && nextY >= 0 && nextY < H && ansMap[nextY][nextX] == -1) { ansMap[nextY][nextX] = (count+1); find = true; } } } } } if(find == false) { System.out.println(count==0? 1500 : count); break; } } } }