#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int cmx = 1e5 + 5;
int n, k;
char a[505][505];
int id[505][505];
int cc_sz[505 * 505];
int seen[505 * 505];
bool inside(int x, int y) {
  if (0 <= min(x, y) and max(x, y) < n) return true;
  return false;
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void dfs(int x, int y, int cc_no) {
  id[x][y] = cc_no;
  cc_sz[cc_no]++;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (inside(nx, ny) and (id[nx][ny] == 0 and a[nx][ny] == '.'))
      dfs(nx, ny, cc_no);
  }
}
void add(int x, int y, int &ans, int flag) {
  if (a[x][y] == '.' and seen[id[x][y]] != flag) {
    seen[id[x][y]] = flag;
    ans += cc_sz[id[x][y]];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (n - 1); ++j) cin >> a[i][j];
  int which_cc = 0;
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (n - 1); ++j) {
      if (id[i][j] == 0 and a[i][j] == '.') {
        dfs(i, j, ++which_cc);
      }
    }
  int counter = 1;
  int best_ans = 0;
  for (int y_low = 0; (y_low + k) <= n; y_low++) {
    for (int x = 0; x < k; x++)
      for (int y = y_low; y < (y_low + k); y++) --cc_sz[id[x][y]];
    for (int x_low = 0; (x_low + k) <= n; x_low++) {
      int ans = k * k;
      for (int x = 0; x < k; x++) {
        if (inside(x_low + x, y_low - 1))
          add(x_low + x, y_low - 1, ans, counter);
        if (inside(x_low + x, y_low + k))
          add(x_low + x, y_low + k, ans, counter);
      }
      for (int y = 0; y < k; y++) {
        if (inside(x_low - 1, y_low + y))
          add(x_low - 1, y_low + y, ans, counter);
        if (inside(x_low + k, y_low + y))
          add(x_low + k, y_low + y, ans, counter);
      }
      counter++;
      best_ans = max(best_ans, ans);
      if ((x_low + k) != n) {
        for (int y = 0; y < k; y++) {
          ++cc_sz[id[x_low][y + y_low]];
          --cc_sz[id[x_low + k][y + y_low]];
        }
      }
    }
    for (int x = n - k; x < n; x++)
      for (int y = 0; y < k; y++) ++cc_sz[id[x][y_low + y]];
  }
  cout << best_ans << '\n';
  return 0;
}
