- const maxn = 700; 
- var n,m:word; 
-     a: array[0..maxn+1,0..maxn+1] of word; 
-     visit: array[0..maxn+1,0..maxn+1] of boolean; 
- procedure enter; 
- var i,j:word; 
- begin 
-   readln(n,m); 
-   for i:=1 to n do 
-   begin 
-     for j:=1 to m do 
-     begin 
-       read(a[i,j]); 
-       visit[i,j]:=false; 
-     end; 
-     readln; 
-   end; 
- end; 
- function dfs(x,y:word):boolean; 
- var p,pp:boolean; 
- begin 
-   p:=true; 
-   visit[x,y]:=true; 
-   if (x>1) and (a[x-1,y]>a[x,y]) then p:=false; 
-   if p and (x<n) and (a[x+1,y]>a[x,y]) then p:=false; 
-   if p and (y>1) and (a[x,y-1]>a[x,y]) then p:=false; 
-   if p and (y<m) and (a[x,y+1]>a[x,y]) then p:=false; 
-   if p and (x>1) and (y>1) and (a[x-1,y-1]>a[x,y]) then p:=false; 
-   if p and (x>1) and (y<m) and (a[x-1,y+1]>a[x,y]) then p:=false; 
-   if p and (x<n) and (y>1) and (a[x+1,y-1]>a[x,y]) then p:=false; 
-   if p and (x<n) and (y<m) and (a[x+1,y+1]>a[x,y]) then p:=false; 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (x>1) and (a[x-1,y]=a[x,y]) and (not visit[x-1,y]) then dfs(x-1,y); 
-     if (x<n) and (a[x+1,y]=a[x,y]) and (not visit[x+1,y]) then dfs(x+1,y); 
-     if (y>1) and (a[x,y-1]=a[x,y]) and (not visit[x,y-1]) then dfs(x,y-1); 
-     if (y<m) and (a[x,y+1]=a[x,y]) and (not visit[x,y+1]) then dfs(x,y+1); 
-     if (x>1) and (y>1) and (a[x-1,y-1]=a[x,y]) and (not visit[x-1,y-1]) then dfs(x-1,y-1); 
-     if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then dfs(x-1,y+1); 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (x>1) and (a[x-1,y]=a[x,y]) and (not visit[x-1,y]) then p:=p and dfs(x-1,y); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (x<n) and (a[x+1,y]=a[x,y]) and (not visit[x+1,y]) then dfs(x+1,y); 
-     if (y>1) and (a[x,y-1]=a[x,y]) and (not visit[x,y-1]) then dfs(x,y-1); 
-     if (y<m) and (a[x,y+1]=a[x,y]) and (not visit[x,y+1]) then dfs(x,y+1); 
-     if (x>1) and (y>1) and (a[x-1,y-1]=a[x,y]) and (not visit[x-1,y-1]) then dfs(x-1,y-1); 
-     if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then dfs(x-1,y+1); 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (x<n) and (a[x+1,y]=a[x,y]) and (not visit[x+1,y]) then p:=p and dfs(x+1,y); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (y>1) and (a[x,y-1]=a[x,y]) and (not visit[x,y-1]) then dfs(x,y-1); 
-     if (y<m) and (a[x,y+1]=a[x,y]) and (not visit[x,y+1]) then dfs(x,y+1); 
-     if (x>1) and (y>1) and (a[x-1,y-1]=a[x,y]) and (not visit[x-1,y-1]) then dfs(x-1,y-1); 
-     if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then dfs(x-1,y+1); 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (y>1) and (a[x,y-1]=a[x,y]) and (not visit[x,y-1]) then p:=p and dfs(x,y-1); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (y<m) and (a[x,y+1]=a[x,y]) and (not visit[x,y+1]) then dfs(x,y+1); 
-     if (x>1) and (y>1) and (a[x-1,y-1]=a[x,y]) and (not visit[x-1,y-1]) then dfs(x-1,y-1); 
-     if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then dfs(x-1,y+1); 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (y<m) and (a[x,y+1]=a[x,y]) and (not visit[x,y+1]) then p:=p and dfs(x,y+1); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (x>1) and (y>1) and (a[x-1,y-1]=a[x,y]) and (not visit[x-1,y-1]) then dfs(x-1,y-1); 
-     if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then dfs(x-1,y+1); 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (x>1) and (y>1) and (a[x-1,y-1]=a[x,y]) and (not visit[x-1,y-1]) then p:=p and dfs(x-1,y-1); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then dfs(x-1,y+1); 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (x>1) and (y<m) and (a[x-1,y+1]=a[x,y]) and (not visit[x-1,y+1]) then p:=p and dfs(x-1,y+1); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then dfs(x+1,y-1); 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (x<n) and (y>1) and (a[x+1,y-1]=a[x,y]) and (not visit[x+1,y-1]) then p:=p and dfs(x+1,y-1); 
-   if not p then 
-   begin 
-     dfs:=p; 
-     if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then dfs(x+1,y+1); 
-   end; 
-   if (x<n) and (y<m) and (a[x+1,y+1]=a[x,y]) and (not visit[x+1,y+1]) then p:=p and dfs(x+1,y+1); 
-   dfs:=p; 
- end; 
- procedure initvisit; 
- var i,j:word; 
- begin 
-   for i:=1 to n do 
-   for j:=1 to m do 
-   visit[i,j]:=false; 
- end; 
- procedure printvisit; 
- var i,j:word; 
- begin 
-   for i:=1 to n do 
-   begin 
-     for j:=1 to m do 
-     write(visit[i,j]:5,' '); 
-     writeln; 
-   end; 
- end; 
- procedure solve; 
- var i,j,res:word; 
-     p:boolean; 
- begin 
-   res:=0; 
-   for i:=1 to n do 
-   for j:=1 to m do 
-   if not visit[i,j] then 
-   if dfs(i,j) then  
-   begin 
-     inc(res); 
-   end; 
-   writeln(res); 
- end; 
- begin 
-   enter; 
-   solve; 
- end. 
-   
-   
-   
				Y29uc3QgbWF4biA9IDcwMDsKdmFyIG4sbTp3b3JkOwogICAgYTogYXJyYXlbMC4ubWF4bisxLDAuLm1heG4rMV0gb2Ygd29yZDsKICAgIHZpc2l0OiBhcnJheVswLi5tYXhuKzEsMC4ubWF4bisxXSBvZiBib29sZWFuOwpwcm9jZWR1cmUgZW50ZXI7CnZhciBpLGo6d29yZDsKYmVnaW4KICByZWFkbG4obixtKTsKICBmb3Iga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