#include <bits/stdc++.h>
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10;
const long long mod7 = 1e9 + 7;
const long long mod9 = 1e9 + 9;
using namespace std;
inline long long rit() {
  long long f = 0, key = 1;
  char c;
  do {
    c = getchar();
    if (c == '-') key = -1;
  } while (c < '0' || c > '9');
  do {
    f = f * 10 + c - '0';
    c = getchar();
  } while (c >= '0' && c <= '9');
  return f * key;
}
inline void fprt(double f) { printf("%.08lf", f); }
void init() {}
const int Z = 505;
int n, k, dir[5] = {Z, -Z, 1, -1, 0}, r;
int cnt[Z * Z], belong[Z * Z], cnt2[Z * Z];
char maap[Z * Z];
queue<int> q;
void flood(int st) {
  int now;
  q.push(st);
  maap[st] = 'X';
  while (!q.empty()) {
    now = q.front();
    q.pop();
    cnt[r]++;
    belong[now] = r;
    for (int i = 0; i < 4; i++) {
      if (maap[dir[i] + now] == '.') {
        maap[dir[i] + now] = 'X';
        q.push(dir[i] + now);
      }
    }
  }
}
void do_bfs() {
  r = 1;
  for (int i = Z; i <= n * Z; i += Z)
    for (int j = 1; j <= n; j++) {
      if (maap[i + j] == '.') {
        flood(i + j);
        r++;
      }
    }
}
int own[Z * Z], sum;
void add(int x) {
  if (!belong[x]) {
    if (!cnt2[x]) sum++;
    cnt2[x]++;
    return;
  }
  x = belong[x];
  if (!own[x]) sum += cnt[x];
  own[x]++;
}
void sub(int x) {
  if (!belong[x]) {
    cnt2[x]--;
    if (!cnt2[x]) sum--;
    return;
  }
  x = belong[x];
  own[x]--;
  if (!own[x]) sum -= cnt[x];
}
void ad2(int x) {
  for (int i = 0; i < 4; i++) {
    if (belong[x + dir[i]]) add(x + dir[i]);
  }
  add(x);
}
void su2(int x) {
  for (int i = 0; i < 4; i++) {
    if (belong[x + dir[i]]) sub(x + dir[i]);
  }
  sub(x);
}
void calc(int x, int x2, int y, int y2) {
  memset((own), 0, sizeof((own)));
  ;
  memset((cnt2), 0, sizeof((cnt2)));
  ;
  sum = 0;
  for (int i = x * Z; i <= x2 * Z; i += Z) {
    for (int j = y; j <= y2; j++) {
      ad2(i + j);
    }
  }
}
void hi(int x, int x2, int y) {
  for (int i = x * Z; i <= x2 * Z; i += Z) {
    ad2(i + y);
  }
}
void bye(int x, int x2, int y) {
  for (int i = x * Z; i <= x2 * Z; i += Z) {
    su2(i + y);
  }
}
void read() {
  n = rit(), k = rit();
  ;
  for (int i = Z; i <= n * Z; i += Z)
    for (int j = 1; j <= n; j++) scanf(" %c", &maap[i + j]);
}
void solve() {
  int i, j, fi, ans = 0;
  do_bfs();
  for (fi = 1; fi + k - 1 <= n; fi++) {
    i = fi * Z;
    calc(fi, fi + k - 1, 1, k);
    ans = max(ans, sum);
    for (j = 2; j + k - 1 <= n; j++) {
      bye(fi, fi + k - 1, j - 1);
      hi(fi, fi + k - 1, j + k - 1);
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}
int main() {
  int nn = 1;
  while (nn--) {
    init(), read(), solve();
  }
  return 0;
}
