#include <bits/stdc++.h>
using namespace std;
int n, k, con[502][502], c = 1, sz[250000], siz, mx, it, vis[250000];
char a[502][502];
vector<int> mp(250000, 0), mp2(250000);
void go(int i, int j) {
  if (i < 0 || i == n || j < 0 || j == n) return;
  if (a[i][j] == 'X' || con[i][j]) return;
  con[i][j] = c;
  siz++;
  go(i + 1, j);
  go(i - 1, j);
  go(i, j + 1);
  go(i, j - 1);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%s", &a[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!con[i][j] && a[i][j] == '.') {
        go(i, j);
        sz[c] = siz;
        c++;
        siz = 0;
      }
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      if (con[i][j]) mp[con[i][j]]++;
    }
  }
  for (int i = 0; i <= n - k; i++) {
    if (i > 0) {
      for (int u = 0; u < k; u++) {
        if (con[i - 1][u]) mp[con[i - 1][u]]--;
        if (con[i + k - 1][u]) mp[con[i + k - 1][u]]++;
      }
    }
    mp2 = mp;
    for (int j = 0; j <= n - k; j++) {
      if (j > 0) {
        for (int u = i; u < i + k; u++) {
          if (con[u][j - 1]) mp2[con[u][j - 1]]--;
          if (con[u][j + k - 1]) mp2[con[u][j + k - 1]]++;
        }
      }
      c = k * k;
      it++;
      if (i > 0) {
        for (int u = j; u < j + k; u++) {
          if (con[i - 1][u] && vis[con[i - 1][u]] < it)
            vis[con[i - 1][u]] = it, c += sz[con[i - 1][u]],
                        c -= mp2[con[i - 1][u]];
        }
      }
      if (j > 0) {
        for (int u = i; u < i + k; u++) {
          if (con[u][j - 1] && vis[con[u][j - 1]] < it)
            vis[con[u][j - 1]] = it, c += sz[con[u][j - 1]],
                           c -= mp2[con[u][j - 1]];
        }
      }
      if (i + k < n) {
        for (int u = j; u < j + k; u++) {
          if (con[i + k][u] && vis[con[i + k][u]] < it)
            vis[con[i + k][u]] = it, c += sz[con[i + k][u]],
                        c -= mp2[con[i + k][u]];
        }
      }
      if (j + k < n) {
        for (int u = i; u < i + k; u++) {
          if (con[u][j + k] && vis[con[u][j + k]] < it)
            vis[con[u][j + k]] = it, c += sz[con[u][j + k]],
                           c -= mp2[con[u][j + k]];
        }
      }
      mx = max(mx, c);
    }
  }
  printf("%d", mx);
  return 0;
}
