/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Main { private static final int[] dx = { 0, 1, 0, -1}; private static final int[] dy = {-1, 0, 1, 0}; private static int H,W; private static int cnt; public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] lines = br.readLine().split(" "); H = Integer.parseInt(lines[0]); W = Integer.parseInt(lines[1]); int[][] map = new int[H][W]; for(int i=0;i stack = new Stack(); stack.push(new Pair(h,w)); while(!stack.isEmpty()){ Pair now = stack.pop(); for(int i=0;i<4;i++){ try{ int n_h = now.h+dx[i]; int n_w = now.w+dy[i]; if(map[n_h][n_w] != color){ map[n_h][n_w] = color; if(map[n_h][n_w] == 0){ cnt++; }else{ cnt--; } stack.push(new Pair(n_h,n_w)); } }catch(Exception e){} } } } private static class Pair{ public int h; public int w; public Pair(int h,int w){ this.h = h; this.w = w; } } }