#include <bits/stdc++.h>
using namespace std;
const long long MXN = 500 + 10;
const long long MXM = MXN * MXN + MXN;
int n, k, ans, now;
int Par[MXM], Sz[MXM];
bool vis[MXN][MXN], mark[MXM];
vector<pair<int, int>> dir = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
vector<int> st;
inline bool check(int x, int y) {
  return ~x && x < n && ~y && y < n && vis[x][y];
}
inline int Get(int x, int y) { return x * n + y; }
int Find(int u) { return (u == Par[u] ? u : Par[u] = Find(Par[u])); }
inline bool Union(int u, int v) {
  u = Find(u), v = Find(v);
  if (u == v) return 0;
  if (Sz[v] < Sz[u]) swap(u, v);
  Par[u] = v, Sz[v] += Sz[u];
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      char ch;
      cin >> ch, vis[x][y] = (ch == '.'), Par[Get(x, y)] = Get(x, y),
                 Sz[Get(x, y)] = vis[x][y];
    }
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      if (!check(x, y)) continue;
      for (auto [dx, dy] : dir) {
        long long xp = x + dx, yp = y + dy;
        if (check(xp, yp)) Union(Get(xp, yp), Get(x, y));
      }
    }
  }
  for (int i = 0; i + k <= n; i++) {
    for (int j = 0; j < k; j++) {
      for (int h = i; h < i + k; h++) {
        if (vis[h][j]) Sz[Find(Get(h, j))]--;
      }
    }
    for (int j = 0; j + k <= n; j++) {
      st.clear(), now = 0;
      if (i) {
        for (int p = j; p < j + k; p++) {
          if (mark[Find(Get(i - 1, p))]) continue;
          mark[Find(Get(i - 1, p))] = 1;
          st.push_back(Find(Get(i - 1, p)));
        }
      }
      if (j) {
        for (int h = i; h < i + k; h++) {
          if (mark[Find(Get(h, j - 1))]) continue;
          mark[Find(Get(h, j - 1))] = 1;
          st.push_back(Find(Get(h, j - 1)));
        }
      }
      if (i + k < n) {
        for (int p = j; p < j + k; p++) {
          if (mark[Find(Get(i + k, p))]) continue;
          mark[Find(Get(i + k, p))] = 1;
          st.push_back(Find(Get(i + k, p)));
        }
      }
      if (j + k < n) {
        for (int h = i; h < i + k; h++) {
          if (mark[Find(Get(h, j + k))]) continue;
          mark[Find(Get(h, j + k))] = 1;
          st.push_back(Find(Get(h, j + k)));
        }
      }
      for (auto X : st) now += Sz[X], mark[X] = 0;
      ans = max(ans, now + k * k);
      for (int h = i; h < i + k; h++) {
        if (vis[h][j]) Sz[Find(Get(h, j))]++;
      }
      if (j + k < n) {
        for (int h = i; h < i + k; h++) {
          if (vis[h][j + k]) Sz[Find(Get(h, j + k))]--;
        }
      }
    }
    for (int j = n - k + 1; j < n; j++) {
      for (int h = i; h < i + k; h++) {
        if (vis[h][j]) Sz[Find(Get(h, j))]++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
