#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int M = 1000000007;
int n, k;
char mp[N][N];
int id[N][N];
int sz[N * N];
int t[N * N];
const int mov[4][2] = {-1, 0, 0, -1, 0, 1, 1, 0};
inline bool judge(int x, int y) { return x >= 0 && x < n && y >= 0 && y < n; }
void dfs(int x, int y, int i) {
  id[x][y] = i;
  sz[i]++;
  for (int d = 0; d < 4; d++) {
    int xx = x + mov[d][0], yy = y + mov[d][1];
    if (judge(xx, yy) && mp[xx][yy] == '.' && !id[xx][yy]) {
      dfs(xx, yy, i);
    }
  }
}
inline int get(int x, int y, int crt) {
  if (judge(x, y) && mp[x][y] == '.' && t[id[x][y]] != crt) {
    t[id[x][y]] = crt;
    return sz[id[x][y]];
  }
  return 0;
}
int main() {
  while (~scanf("%d%d", &n, &k)) {
    memset(id, 0, sizeof id);
    memset(sz, 0, sizeof sz);
    memset(t, 0, sizeof t);
    for (int i = 0; i < n; i++) {
      scanf("%s", mp[i]);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (mp[i][j] == '.' && !id[i][j]) {
          dfs(i, j, ++cnt);
        }
      }
    }
    int ans = 0;
    int ai, aj;
    for (int jj = 0, crt = 1; jj + k <= n; jj++) {
      for (int i = 0; i < k; i++) {
        for (int j = jj; j < jj + k; j++) {
          sz[id[i][j]]--;
        }
      }
      for (int ii = 0; ii + k <= n; ii++) {
        int ret = k * k;
        for (int i = ii; i < ii + k; i++) {
          ret += get(i, jj - 1, crt);
          ret += get(i, jj + k, crt);
        }
        for (int j = jj; j < jj + k; j++) {
          ret += get(ii - 1, j, crt);
          ret += get(ii + k, j, crt);
        }
        if (ii + k != n) {
          for (int j = jj; j < jj + k; j++) {
            sz[id[ii][j]]++;
            sz[id[ii + k][j]]--;
          }
        }
        ans = max(ans, ret);
        crt++;
      }
      for (int i = n - k; i < n; i++) {
        for (int j = jj; j < jj + k; j++) {
          sz[id[i][j]]++;
        }
      }
    }
    printf("%d\n", ans);
  }
}
