#include <bits/stdc++.h>
using namespace std;
const int INF = (-1u) / 2;
const long long int INF2 = (-1ull) / 2;
int a, b, i, d[1011000], j, k, n, m, timer = 0, l, r, x, y, f[1000010];
int us[1011000], cnt = 0, fl = 0, a2, a3 = -1000000, ans = 0;
string s[10010];
int id(int a, int b) { return a * m + b + 1; }
void deb(bool a) {
  if (a) return;
  printf("PROGRAM TERMINATED\n");
  exit(0);
}
void dfs(int x, int y, int cnt) {
  if (!(x >= 0 && x < n && y >= 0 && y < m && s[x][y] == '.' &&
        us[id(x, y)] == 0))
    return;
  us[id(x, y)] = cnt;
  l++;
  dfs(x + 1, y, cnt);
  dfs(x - 1, y, cnt);
  dfs(x, y + 1, cnt);
  dfs(x, y - 1, cnt);
}
void solve(int x, int y) {
  r++;
  int res = 0;
  for (int i = x; i < x + k; i++) {
    if (y && s[i][y - 1] == '.' && f[us[id(i, y - 1)]] != r) {
      f[us[id(i, y - 1)]] = r;
      res += d[us[id(i, y - 1)]];
    }
    if (y + k < m && s[i][y + k] == '.' && f[us[id(i, y + k)]] != r) {
      f[us[id(i, y + k)]] = r;
      res += d[us[id(i, y + k)]];
    }
  }
  for (int j = y; j < y + k; j++) {
    if (x && s[x - 1][j] == '.' && f[us[id(x - 1, j)]] != r) {
      f[us[id(x - 1, j)]] = r;
      res += d[us[id(x - 1, j)]];
    }
    if (x + k < n && s[x + k][j] == '.' && f[us[id(x + k, j)]] != r) {
      f[us[id(x + k, j)]] = r;
      res += d[us[id(x + k, j)]];
    }
  }
  res += k * k;
  ans = max(ans, res);
  if (y + k < m) {
    for (i = x; i < x + k; i++) {
      if (s[i][y] == '.') d[us[id(i, y)]]++;
      if (s[i][y + k] == '.') d[us[id(i, y + k)]]--;
    }
    solve(x, y + 1);
    for (i = x; i < x + k; i++) {
      if (s[i][y] == '.') d[us[id(i, y)]]--;
      if (s[i][y + k] == '.') d[us[id(i, y + k)]]++;
    }
  }
  if (y == 0 && x + k < n) {
    for (j = y; j < y + k; j++) {
      if (s[x][j] == '.') d[us[id(x, j)]]++;
      if (s[x + k][j] == '.') d[us[id(x + k, j)]]--;
    }
    solve(x + 1, y);
    for (j = y; j < y + k; j++) {
      if (s[x][j] == '.') d[us[id(x, j)]]--;
      if (s[x + k][j] == '.') d[us[id(x + k, j)]]++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  m = n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s[i][j] == '.' && us[id(i, j)] == 0) {
        l = 0;
        dfs(i, j, ++cnt);
        d[cnt] = l;
      }
    }
  }
  for (i = 0; i < k; i++) {
    for (j = 0; j < k; j++) {
      if (s[i][j] == '.') {
        d[us[id(i, j)]]--;
      }
    }
  }
  solve(0, 0);
  cout << ans << endl;
  return 0;
}
