#include <bits/stdc++.h>
using namespace std;
char b[502][502];
int pos = 1, id[502][502], sz[502 * 502], dy[4] = {1, -1, 0, 0},
    dx[4] = {0, 0, 1, -1};
bool is[502 * 502], s[502][502];
void dfs(int y, int x, int ID) {
  int i, u, ny, nx;
  id[y][x] = ID;
  ++sz[ID];
  for (i = 0; i < 4; ++i) {
    ny = y + dy[i], nx = x + dx[i];
    if (id[ny][nx] == -1 && b[ny][nx] == '.') {
      dfs(ny, nx, ID);
    }
  }
}
int main() {
  int n, k, i, j;
  cin >> n >> k;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
      cin >> b[i][j];
    }
  }
  memset(id, -1, sizeof(id));
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
      if (id[i][j] == -1 && b[i][j] == '.') dfs(i, j, pos), ++pos;
    }
  }
  vector<int> v;
  int ret = 0, cand, x, u, y;
  for (i = 1; i <= n - k + 1; ++i) {
    for (j = 0; j <= n - k + 1; ++j) {
      if (j == 0) {
        for (x = 0; x < k; ++x)
          for (y = 0; y < k; ++y)
            if (id[i + x][j + y + 1] > 0) --sz[id[i + x][j + y + 1]];
        continue;
      }
      cand = k * k;
      for (x = j; x < j + k; ++x) {
        u = id[i - 1][x];
        if (u != -1 && !is[u]) cand += sz[u], is[u] = 1, v.push_back(u);
        u = id[i + x - j][j - 1];
        if (u != -1 && !is[u]) cand += sz[u], is[u] = 1, v.push_back(u);
        u = id[i + x - j][j + k];
        if (u != -1 && !is[u]) cand += sz[u], is[u] = 1, v.push_back(u);
        u = id[i + k][x];
        if (u != -1 && !is[u]) cand += sz[u], is[u] = 1, v.push_back(u);
      }
      if (j != n - k + 1) {
        for (x = 0; x < k; ++x)
          if (id[i + x][j] > 0) ++sz[id[i + x][j]];
        for (x = 0; x < k; ++x)
          if (id[i + x][j + k] > 0) --sz[id[i + x][j + k]];
      } else {
        for (x = 0; x < k; ++x)
          for (y = 0; y < k; ++y)
            if (id[i + x][j + y] > 0) ++sz[id[i + x][j + y]];
      }
      for (x = 0; x < v.size(); ++x) {
        is[v[x]] = 0;
      }
      v.clear();
      ret = max(ret, cand);
    }
  }
  cout << ret << endl;
}
