defcheck_route(N,L,route):ramp=[0]*Nforiinrange(N-1):ifabs(route[i]-route[i+1])>1:returnFalseelse:#높이차이가 1이거나 0인 경우
ifroute[i]-route[i+1]==1:#높은 칸에서 낮은 칸
ifi+1+L>N:returnFalsecheck=route[i+1]forjinrange(i+1,i+1+L):iframp[j]orroute[j]!=check:returnFalseramp[j]=1elifroute[i]-route[i+1]==-1:ifi-L<-1:returnFalsecheck=route[i]forjinrange(i,i-L,-1):iframp[j]orroute[j]!=check:returnFalseramp[j]=1returnTrueN,L=map(int,input().split())board=[list(map(int,input().split()))for_inrange(N)]cnt=0forrinboard:ifcheck_route(N,L,r):cnt+=1T_board=[list(x)forxinzip(*board)]forrinT_board:ifcheck_route(N,L,r):cnt+=1print(cnt)