#include <bits/stdc++.h>
using namespace std;
struct {
  int x[550 * 550], siz[550 * 550];
  void init() {
    for (int i = 0; i < 550 * 550; ++i) x[i] = i, siz[i] = 1;
  }
  int Find(int now) { return x[now] == now ? now : x[now] = Find(x[now]); }
  void Union(int a, int b) {
    a = Find(a), b = Find(b);
    if (a != b) x[b] = a, siz[a] += siz[b];
  }
  int operator[](int now) { return Find(now); }
} ds;
int n, m, sum[550][550];
string s[550];
int IN(int a, int b) {
  return a >= 0 && a < n && b >= 0 && b < n && s[a][b] == '.';
}
int id[550][550], po = 1, cnt[550 * 550], use[550 * 550];
int32_t main() {
  ds.init();
  cin.tie(), cout.sync_with_stdio(0), cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) id[i][j] = po++;
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (s[i][j] == '.' && s[i - 1][j] == '.')
        ds.Union(id[i][j], id[i - 1][j]);
  for (int i = 0; i < n; ++i)
    for (int j = 1; j < n; ++j)
      if (s[i][j] == '.' && s[i][j - 1] == '.')
        ds.Union(id[i][j], id[i][j - 1]);
  for (int i = 0; i < n; ++i) {
    if (i + m - 1 >= n) break;
    memset(cnt, 0, sizeof cnt);
    int fr = 0, ba = m - 1;
    for (int ii = i; ii < i + m; ++ii) {
      for (int jj = 0; jj < m - 1; ++jj) {
        if (s[ii][jj] == '.') cnt[ds[id[ii][jj]]]++;
      }
    }
    while (ba < n) {
      for (int ii = i; ii < i + m; ++ii)
        if (s[ii][ba] == '.') cnt[ds[id[ii][ba]]]++;
      vector<int> sol;
      for (int jj = fr; jj < ba + 1; ++jj)
        if (IN(i - 1, jj)) sol.push_back(id[i - 1][jj]);
      for (int jj = fr; jj < ba + 1; ++jj)
        if (IN(i + m, jj)) sol.push_back(id[i + m][jj]);
      for (int ii = i; ii < i + m; ++ii)
        if (IN(ii, fr - 1)) sol.push_back(id[ii][fr - 1]);
      for (int ii = i; ii < i + m; ++ii)
        if (IN(ii, ba + 1)) sol.push_back(id[ii][ba + 1]);
      int tmp = m * m;
      for (auto to : sol) {
        int now = ds[to];
        if (use[now] == 0) use[now] = 1, tmp += ds.siz[now] - cnt[now];
      }
      for (auto to : sol) use[ds[to]] = 0;
      sum[i][fr] = tmp;
      for (int ii = i; ii < i + m; ++ii)
        if (s[ii][fr] == '.') cnt[ds[id[ii][fr]]]--;
      fr++, ba++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) ans = max(ans, sum[i][j]);
  cout << ans << "\n";
  return 0;
}
