#include <bits/stdc++.h>
using namespace std;
const int N = 505, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int n, m, sz, p[N][N], c[N * N], ans, sum, last[N * N], tim;
char a[N][N];
inline bool check(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= n; }
void dfs(int x, int y) {
  p[x][y] = sz;
  c[sz]++;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (check(xx, yy) && !p[xx][yy] && a[xx][yy] == '.') {
      dfs(xx, yy);
    }
  }
}
void upd(int x, int y) {
  if (check(x, y) && a[x][y] == '.') {
    int z = p[x][y];
    if (last[z] != tim) {
      sum += c[z];
      last[z] = tim;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == '.' && !p[i][j]) {
        sz++;
        dfs(i, j);
      }
    }
  }
  memset(last, -1, sizeof(last));
  for (int i = 1; i + m - 1 <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = i; k <= i + m - 1; k++) {
        c[p[j][k]]--;
      }
    }
    for (int j = 1; j + m - 1 <= n; j++) {
      sum = m * m;
      for (int k = j; k <= j + m - 1; k++) {
        upd(k, i - 1);
        upd(k, i + m);
      }
      for (int k = i; k <= i + m - 1; k++) {
        upd(j - 1, k);
        upd(j + m, k);
      }
      tim++;
      ans = max(ans, sum);
      if (j + m <= n) {
        for (int k = i; k <= i + m - 1; k++) {
          c[p[j][k]]++;
          c[p[j + m][k]]--;
        }
      }
    }
    for (int j = n - m + 1; j <= n; j++) {
      for (int k = i; k <= i + m - 1; k++) {
        c[p[j][k]]++;
      }
    }
  }
  cout << ans;
}
