#include <bits/stdc++.h>
using namespace std;
char grid[505][505];
int cc[505][505];
int T = 0, n, k, no_cc = 0;
vector<int> sz, when;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int dfs(int x, int y, int wcc) {
  if (x < 1 || x > n || y < 1 || y > n || grid[x][y] == 'X' || cc[x][y] != 0)
    return 0;
  cc[x][y] = wcc;
  int s = 1;
  for (int i = 0; i < 4; i++) s += dfs(x + dx[i], y + dy[i], wcc);
  return s;
}
int add(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > n || grid[x][y] == 'X' ||
      when[cc[x][y]] == T)
    return 0;
  when[cc[x][y]] = T;
  return sz[cc[x][y]];
}
void answer() {
  int x, y, cur, i, j, ans = k * k;
  T = 1;
  for (i = 1; i <= n - k + 1; i++) {
    for (x = i; x <= i + k - 1; x++)
      for (y = 1; y <= k; y++)
        if (grid[x][y] == '.') sz[cc[x][y]]--;
    for (j = 1; j <= n - k + 1; j++) {
      cur = k * k;
      for (x = i; x <= k + i - 1; x++) {
        cur += add(x, j - 1);
        cur += add(x, j + k);
      }
      for (y = j; y <= k + j - 1; y++) {
        cur += add(i - 1, y);
        cur += add(i + k, y);
      }
      ans = max(ans, cur);
      T++;
      if (j != n - k + 1) {
        for (x = i; x <= k + i - 1; x++) {
          if (grid[x][j] == '.') sz[cc[x][j]]++;
          if (grid[x][j + k] == '.') sz[cc[x][j + k]]--;
        }
      }
    }
    for (x = i; x <= i + k - 1; x++)
      for (y = n - k + 1; y <= n; y++)
        if (grid[x][y] == '.') sz[cc[x][y]]++;
  }
  cout << ans << endl;
}
int main() {
  int i, j;
  char temp[505];
  memset(cc, 0, sizeof(cc));
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    scanf("%s", temp);
    for (j = 1; j <= n; j++) grid[i][j] = temp[j - 1];
  }
  sz.push_back(0);
  when.push_back(0);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (grid[i][j] == '.' && cc[i][j] == 0) {
        no_cc++;
        sz.push_back(dfs(i, j, no_cc));
        when.push_back(0);
      }
  answer();
  return 0;
}
