#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <class T>
int sgn(T x) {
  return x > 0 ? 1 : (x < 0 ? -1 : 0);
}
const long double pi = 2 * asinl((long double)1.0);
int n;
int m;
const int N = 510;
char s[N][N], was[N][N], mark[N * N];
int color[N][N], cnt[N * N];
void add(int& res, int i, int j) {
  if (!mark[color[i][j]]) {
    res += cnt[color[i][j]];
    mark[color[i][j]] = true;
  }
}
void unmark(int i, int j) { mark[color[i][j]] = false; }
int main() {
  int k;
  scanf("%d%d -", &n, &k);
  memset(s, 'X', sizeof(s));
  for (int i = 1; i <= n; i++) gets(s[i] + 1);
  int ct = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (color[i][j] || s[i][j] == 'X') continue;
      ct++;
      vector<pair<int, int> > q;
      int l = 0;
      q.push_back(make_pair(i, j));
      was[i][j] = true;
      while (l < ((int)q.size())) {
        pair<int, int> pos = q[l++];
        color[pos.first][pos.second] = ct;
        for (int dx = -1; dx <= 1; dx++)
          for (int dy = -1; dy <= 1; dy++) {
            if (abs(dx) + abs(dy) != 1) continue;
            pair<int, int> npos = make_pair(pos.first + dx, pos.second + dy);
            if (npos.first <= 0 || npos.second <= 0 || npos.first > n ||
                npos.second > n)
              continue;
            if (s[npos.first][npos.second] == 'X') continue;
            if (!was[npos.first][npos.second]) {
              q.push_back(npos);
              was[npos.first][npos.second] = true;
            }
          }
      }
      cnt[ct] = ((int)q.size());
    }
  int ans = 0;
  for (int i = 1; i <= n - k + 1; i++) {
    for (int p = 0; p < k; p++)
      for (int j = 1; j <= k; j++)
        if (s[i + p][j] == '.') cnt[color[i + p][j]]--;
    for (int j = 1; j <= n - k + 1; j++) {
      int res = 0;
      for (int p = 0; p < k; p++) {
        add(res, p + i, j - 1);
        add(res, p + i, j + k);
        add(res, i - 1, p + j);
        add(res, i + k, p + j);
      }
      for (int p = i; p < i + k; p++) {
        if (s[p][j] == '.') cnt[color[p][j]]++;
        if (s[p][j + k] == '.') cnt[color[p][j + k]]--;
      }
      for (int p = 0; p < k; p++) {
        unmark(p + i, j - 1);
        unmark(p + i, j + k);
        unmark(i - 1, p + j);
        unmark(i + k, p + j);
      }
      ans = max(ans, res);
    }
    for (int p = 0; p < k; p++)
      for (int j = n - k + 2; j <= n; j++) {
        if (s[i + p][j] == '.') cnt[color[i + p][j]]++;
      }
  }
  cout << k * k + ans << endl;
  return 0;
}
