#include <bits/stdc++.h>
using namespace std;
long long mul(long long a, long long b) { return (a * b) % (100000007); }
long long add(long long a, long long b) { return (a + b) % (100000007); }
long long sub(long long a, long long b) {
  return (a - b + llabs(a - b) / (100000007) * (100000007) + (100000007)) %
         (100000007);
}
void upd(long long &a, long long b) {
  a = (a % (100000007) + b % (100000007)) % (100000007);
}
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, k;
int a[(510)][(510)], c_sz[(510) * (510)] = {0}, c[(510)][(510)] = {0};
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int mark[(510) * (510)] = {0};
bool inside(int x, int y) { return 0 < min(x, y) && max(x, y) <= n; }
void dfs(int x, int y, int col) {
  c[x][y] = col;
  c_sz[col]++;
  for (int di = 0; di < 4; di++) {
    int nx = x + dir[di][0], ny = y + dir[di][1];
    if (inside(nx, ny) && a[nx][ny] && !c[nx][ny]) dfs(nx, ny, col);
  }
}
void modi(int x, int y, int t, int &ans) {
  int id = c[x][y];
  if (!inside(x, y) || !a[x][y]) return;
  if (mark[id] != t) {
    mark[id] = t;
    ans += c_sz[id];
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    char s[(510)];
    cin >> (s + 1);
    for (int j = 1; j <= n; j++) a[i][j] = (s[j] == '.');
  }
  int tot = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[i][j] && c[i][j] == 0) {
        dfs(i, j, ++tot);
      }
  int bestans = 0, cur_time = 1;
  for (int i = 1; i <= n - k + 1; i++) {
    for (int x = i; x <= i + k - 1; x++)
      for (int y = 1; y <= k; y++) {
        if (c[x][y]) --c_sz[c[x][y]];
      }
    for (int j = 1; j <= n - k + 1; j++) {
      int ans = 0;
      for (int l = 1; l <= k; l++) {
        modi(i - 1, j + l - 1, cur_time, ans);
        modi(i + k, j + l - 1, cur_time, ans);
        modi(i + l - 1, j - 1, cur_time, ans);
        modi(i + l - 1, j + k, cur_time, ans);
      }
      bestans = max(bestans, ans);
      ++cur_time;
      if (j < n - k + 1)
        for (int l = 1; l <= k; l++) {
          if (c[i + l - 1][j]) ++c_sz[c[i + l - 1][j]];
          if (c[i + l - 1][j + k]) --c_sz[c[i + l - 1][j + k]];
        }
    }
    for (int x = i; x <= i + k - 1; x++)
      for (int y = n - k + 1; y <= n; y++) {
        if (c[x][y]) ++c_sz[c[x][y]];
      }
  }
  cout << bestans + k * k << endl;
  return 0;
}
