#include <bits/stdc++.h>
using namespace std;
int n, k, Ti = 0, component[1005][1005] = {0}, componentSize[250005] = {0},
          g = 0, dr[4] = {1, -1, 0, 0}, dc[4] = {0, 0, -1, 1};
char table[1005][1005] = {0};
bool vis[250005] = {0};
vector<int> v;
void dfs(int r, int c, int group) {
  component[r][c] = group;
  componentSize[g]++;
  for (int i = 0; i <= 3; i++) {
    int rr = r + dr[i], cc = c + dc[i];
    if (component[rr][cc] == 0 && table[rr][cc] == '.') {
      dfs(rr, cc, group);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  vis[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cin >> table[i][j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (component[i][j] == 0 && table[i][j] == '.') {
        dfs(i, j, ++g);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i + k - 1 <= n) {
      for (int l = i; l <= i + k - 1; l++) {
        for (int m = 1; m <= k; m++) {
          if (table[l][m] == '.') {
            componentSize[component[l][m]]--;
          }
        }
      }
    }
    for (int j = 1; j <= n; j++) {
      if (i + k - 1 <= n && j + k - 1 <= n) {
        int temp = k * k;
        for (int l = i; l <= i + k - 1; l++) {
          for (int c = 0; c <= 3; c++) {
            int t1 = l + dr[c], t2 = j + dc[c];
            if (vis[component[t1][t2]] == 0) {
              v.push_back(component[t1][t2]);
              vis[component[t1][t2]] = 1;
            }
            t2 = j + k - 1 + dc[c];
            if (vis[component[t1][t2]] == 0) {
              v.push_back(component[t1][t2]);
              vis[component[t1][t2]] = 1;
            }
          }
        }
        for (int l = j; l <= j + k - 1; l++) {
          for (int c = 0; c <= 3; c++) {
            int t1 = i + dr[c], t2 = l + dc[c];
            if (vis[component[t1][t2]] == 0) {
              v.push_back(component[t1][t2]);
              vis[component[t1][t2]] = 1;
            }
            t1 = i + k - 1 + dr[c];
            if (vis[component[t1][t2]] == 0) {
              v.push_back(component[t1][t2]);
              vis[component[t1][t2]] = 1;
            }
          }
        }
        for (int t : v) {
          temp += componentSize[t];
          vis[t] = 0;
        }
        v.clear();
        Ti = max(Ti, temp);
      }
      if (i + k - 1 <= n) {
        for (int l = i; l <= i + k - 1; l++) {
          if (table[l][j] == '.') componentSize[component[l][j]]++;
          if (table[l][j + k] == '.') componentSize[component[l][j + k]]--;
        }
      }
    }
  }
  cout << Ti << endl;
  return 0;
}
