H,W,N = map(int, input().split()) ans = 1 c = [list(map(int, input().split())) for _ in range(H)] ran = [] for i in range(H): for j in range(W-1): a = c[i][j] b = c[i][j+1] if(a!=b): if(a=mx): mx = r[0] ans += 1 print(ans)