#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &first) {
  char ch;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-';) ch = getchar();
  first = 0;
  int t = 1;
  if (ch == '-') {
    ch = getchar();
    t = -1;
  }
  for (; ch >= '0' && ch <= '9'; ch = getchar()) first = first * 10 + ch - '0';
  first *= t;
}
int fa[250010], size[250010], b[250010], s[1010], f[510][510], mi0[250010],
    mi1[250010], ma0[250010], ma1[250010];
char a[510][510];
bool ok[250010];
int find(int first) {
  if (first != fa[first]) fa[first] = find(fa[first]);
  return fa[first];
}
void merge(int first, int second) {
  first = find(first);
  second = find(second);
  if (first != second) {
    fa[first] = second;
    size[second] += size[first];
    mi0[second] = min(mi0[second], mi0[first]);
    ma0[second] = max(ma0[second], ma0[first]);
    mi1[second] = min(mi1[second], mi1[first]);
    ma1[second] = max(ma1[second], ma1[first]);
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[i][j] = (i - 1) * n + j;
  for (int i = 1; i <= n * n; i++) fa[i] = i;
  for (int i = 1; i <= n * n; i++)
    if (a[(i - 1) / n + 1][(i - 1) % n + 1] == '.')
      size[i] = 1;
    else
      size[i] = 0;
  for (int i = 1; i <= n * n; i++) {
    mi0[i] = ma0[i] = (i - 1) / n + 1;
    mi1[i] = ma1[i] = (i - 1) % n + 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i < n && a[i][j] == '.' && a[i + 1][j] == '.')
        merge(f[i][j], f[i + 1][j]);
      if (j < n && a[i][j] == '.' && a[i][j + 1] == '.')
        merge(f[i][j], f[i][j + 1]);
    }
  int ans = 0;
  for (int i = 1; i <= n - k + 1; i++) {
    memset(s, 0, sizeof(s));
    for (int j = 1; j <= n * n; j++)
      if (fa[j] == j && i <= mi0[j] && i + k - 1 >= ma0[j]) {
        int t = ma1[j] - mi1[j] + 1;
        t = k - t + 1;
        if (t > 0) {
          s[max(1, mi1[j] - t + 1)] += max(1, size[j]);
          s[mi1[j] + 1] -= max(1, size[j]);
        }
      }
    for (int j = 1; j <= n - k + 1; j++) s[j] += s[j - 1];
    for (int j = 1; j <= n - k + 1; j++) {
      int cnt = 0, tmp = s[j];
      if (i > 1)
        for (int p = j; p < j + k; p++) {
          int first = find(f[i - 1][p]);
          if (!ok[first]) {
            ok[first] = 1;
            b[++cnt] = first;
            tmp += size[first];
          }
        }
      if (i + k <= n)
        for (int p = j; p < j + k; p++) {
          int first = find(f[i + k][p]);
          if (!ok[first]) {
            ok[first] = 1;
            b[++cnt] = first;
            tmp += size[first];
          }
        }
      if (j > 1)
        for (int p = i; p < i + k; p++) {
          int first = find(f[p][j - 1]);
          if (!ok[first]) {
            ok[first] = 1;
            b[++cnt] = first;
            tmp += size[first];
          }
        }
      if (j + k <= n)
        for (int p = i; p < i + k; p++) {
          int first = find(f[p][j + k]);
          if (!ok[first]) {
            ok[first] = 1;
            b[++cnt] = first;
            tmp += size[first];
          }
        }
      ans = max(ans, tmp);
      for (int p = 1; p <= cnt; p++) ok[b[p]] = 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}
