#include <bits/stdc++.h>
using namespace std;
int yalla = 1, n, k, dr[] = {1, 0, -1, 0}, dc[] = {0, 1, 0, -1}, ct,
    lel[501 * 501], freq[501 * 501], ans, blocks, mx;
vector<int> temp;
bool vis[501][501], troll[501 * 501];
int id[501][501];
char a[501][501];
void dfs(int x, int y) {
  ct++;
  vis[x][y] = 1;
  id[x][y] = yalla;
  for (int i = 0; i < 4; i++)
    if (x + dr[i] < n && x + dr[i] >= 0 && y + dc[i] < n && y + dc[i] >= 0 &&
        !vis[x + dr[i]][y + dc[i]] && a[x + dr[i]][y + dc[i]] == '.')
      dfs(x + dr[i], y + dc[i]);
}
void add(int col, int row, int val) {
  for (int i = row; i <= row + k - 1 && i < n; i++) {
    if (a[i][col] == '.') {
      if (freq[id[i][col]] == 0 && val == 1)
        ans += lel[id[i][col]];
      else if (freq[id[i][col]] == 1 && val == -1)
        ans -= lel[id[i][col]];
      freq[id[i][col]] += val;
    } else
      blocks += val;
  }
}
void boredom1(int row, int col) {
  if (row < 0 || row >= n) return;
  for (int i = col; i < col + k && i < n; i++)
    if (a[row][i] == '.') temp.push_back(id[row][i]);
}
void boredom2(int row, int col) {
  if (col < 0 || col >= n) return;
  for (int i = row; i < row + k && i < n; i++)
    if (a[i][col] == '.') temp.push_back(id[i][col]);
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (!vis[i][j] && a[i][j] == '.') {
        dfs(i, j);
        lel[yalla] = ct;
        ct = 0;
        yalla++;
      }
  int col_1 = 0, col_2 = 0, row = 0;
  for (; row + k - 1 < n; row++) {
    col_1 = 0, col_2 = 0;
    while (col_1 < n) {
      while (col_2 - col_1 < k && col_2 < n) {
        add(col_2, row, 1);
        col_2++;
      }
      if (col_2 - col_1 == k) {
        int curr = ans + blocks;
        boredom1(row - 1, col_1);
        boredom1(row + k, col_1);
        boredom2(row, col_1 - 1);
        boredom2(row, col_2);
        for (int i = 0; i < temp.size(); i++) {
          if (freq[temp[i]] || troll[temp[i]]) continue;
          curr += lel[temp[i]];
          troll[temp[i]] = 1;
        }
        for (int i = 0; i < temp.size(); i++) {
          troll[temp[i]] = 0;
        }
        temp.clear();
        mx = max(curr, mx);
      }
      add(col_1, row, -1);
      col_1++;
    }
  }
  cout << mx;
}
