#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
int n, k;
string a[maxn];
int sz[maxn * maxn], cnt, used[maxn][maxn];
int scnt[maxn * maxn];
int sumsz = 0, pref[maxn][maxn];
int sm(int x0, int y0, int x1, int y1) {
  return pref[x1][y1] - pref[x0][y1] - pref[x1][y0] + pref[x0][y0];
}
void sadd(int id, int d) {
  if (scnt[id] > 0) sumsz -= sz[id];
  scnt[id] += d;
  if (scnt[id] > 0) sumsz += sz[id];
}
int dfs(int x, int y) {
  if (used[x][y] != -1 || a[x][y] == 'X') return 0;
  used[x][y] = cnt;
  const int dx[] = {-1, 1, 0, 0};
  const int dy[] = {0, 0, -1, 1};
  int ans = 1;
  for (int d = 0; d < 4; ++d) {
    int nx = x + dx[d], ny = y + dy[d];
    if (nx < 0 || nx >= n || ny < 0 || ny >= n) continue;
    ans += dfs(nx, ny);
  }
  return ans;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = "X" + a[i] + "X";
  }
  n += 2;
  a[0] = string(n, 'X');
  a[n - 1] = string(n, 'X');
  memset(pref, 0, sizeof(pref));
  memset(used, -1, sizeof(used));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      pref[i + 1][j + 1] = pref[i + 1][j] + pref[i][j + 1] - pref[i][j] +
                           (a[i][j] == 'X' ? 1 : 0);
      if (a[i][j] != 'X' && used[i][j] == -1) {
        sz[cnt] = dfs(i, j);
        cnt++;
      }
    }
  }
  int ans = -1;
  for (int i = 1; i + k < n; ++i) {
    memset(scnt, 0, sizeof(scnt));
    sumsz = 0;
    for (int j = -1; j <= k; ++j) {
      for (int z = -1; z <= k; ++z) {
        if ((j == -1 || j == k) && (z == -1 || z == k)) continue;
        if (a[i + j][1 + z] == 'X') continue;
        sadd(used[i + j][1 + z], 1);
      }
    }
    int cur = sumsz + sm(i, 1, i + k, 1 + k);
    ans = max(ans, cur);
    for (int q = 2; q + k < n; ++q) {
      for (int j : {-1, k}) {
        for (int z = 0; z < k; ++z) {
          if (a[i + j][q - 1 + z] == 'X') continue;
          sadd(used[i + j][q - 1 + z], -1);
        }
      }
      for (int j = 0; j < k; ++j) {
        for (int z : {-1}) {
          if (a[i + j][q - 1 + z] == 'X') continue;
          sadd(used[i + j][q - 1 + z], -1);
        }
      }
      for (int j : {-1, k}) {
        for (int z = 0; z < k; ++z) {
          if (a[i + j][q + z] == 'X') continue;
          sadd(used[i + j][q + z], 1);
        }
      }
      for (int j = 0; j < k; ++j) {
        for (int z : {k}) {
          if (a[i + j][q + z] == 'X') continue;
          sadd(used[i + j][q + z], 1);
        }
      }
      int cur = sumsz + sm(i, q, i + k, q + k);
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}
