H, W, K = map(int, input().split()) grid = [input().strip() for _ in range(H)] count = 0 for a in range(H): for b in range(W): charset = set() max_s = min(H - a, W - b) for s in range(1, max_s + 1): # Add new row (a + s - 1) from column b to b + s - 1 new_row = a + s - 1 for j in range(b, b + s): c = grid[new_row][j] if c not in charset: charset.add(c) # Add new column (b + s - 1) from row a to a + s - 2 (excluding the last cell) new_col = b + s - 1 for i in range(a, a + s - 1): c = grid[i][new_col] if c not in charset: charset.add(c) # Check current count current = len(charset) if current == K: count += 1 elif current > K: break # Further expansion won't reduce the count print(count)