#include bool f[3001][3001]; bool c[3001][3001]; int ans=0; int h,w; void check(short i,short j,bool aa){ if ((i<0)||(i>=h)) return; if ((j<0)||(j>=w)) return; if (c[i][j]) return; else if (!f[i][j]) return; else if (aa) { ++ans; } c[i][j]=true; check(i-1,j,false); check(i+1,j,false); check(i,j-1,false); check(i,j+1,false); } int main() { scanf("%d %d", &h, &w); for (short i=0;i