#include <bits/stdc++.h>
using namespace std;
const int N = 510, N2 = N * N;
const int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
string s[N];
bitset<N> vis[N];
int sz[N2], comp[N][N];
int n, k;
int cnt[N2];
int sum;
int pre[N][N];
void add(int x) {
  if (x != -1 && cnt[x]++ == 0) sum += sz[x];
}
void rem(int x) {
  if (x != -1 && --cnt[x] == 0) sum -= sz[x];
}
bool valid(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < n); }
void dfs(int x, int y, int c) {
  vis[x][y] = true;
  sz[c]++;
  comp[x][y] = c;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (valid(nx, ny) && s[nx][ny] == '.' && !vis[nx][ny]) dfs(nx, ny, c);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> s[i];
  int ans = k * k, C = 0;
  memset(comp, -1, sizeof comp);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (!vis[i][j] && s[i][j] == '.') {
        dfs(i, j, C++);
        ans = max(ans, sz[C - 1]);
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      pre[i + 1][j + 1] =
          (s[i][j] == 'X' ? 1 : 0) + pre[i][j + 1] + pre[i + 1][j] - pre[i][j];
  for (int c = 0; c <= n - k; c++) {
    sum = 0;
    for (int i = 0; i < C; i++) cnt[i] = 0;
    for (int er = 0; er <= n; er++) {
      if (er < n)
        for (int i = c; i < c + k; i++) add(comp[er][i]);
      if (valid(er - 1, c - 1)) add(comp[er - 1][c - 1]);
      if (valid(er - 1, c + k)) add(comp[er - 1][c + k]);
      if (er - k - 2 >= 0)
        for (int i = c; i < c + k; i++) rem(comp[er - k - 2][i]);
      if (valid(er - k - 1, c - 1)) rem(comp[er - k - 1][c - 1]);
      if (valid(er - k - 1, c + k)) rem(comp[er - k - 1][c + k]);
      int temp = sum;
      temp += pre[er][c + k] - (er - k >= 0 ? pre[er - k][c + k] : 0) -
              pre[er][c] + (er - k >= 0 ? pre[er - k][c] : 0);
      ans = max(ans, temp);
    }
  }
  cout << ans << endl;
}
