#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int walk[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int maxn = 510, maxm = 510;
int n, K;
int N;
int bel[maxn + 5][maxm + 5];
int sz[maxn * maxm + 5];
char g[maxn + 5][maxm + 5];
bool vis[maxn + 5][maxm + 5];
void dfs(int first, int second, int col) {
  vis[first][second] = 1;
  bel[first][second] = col;
  ++sz[col];
  for (int i = (0), _end_ = (4); i < _end_; ++i) {
    int u = first + walk[i][0], v = second + walk[i][1];
    if (u < 0 || u >= n || v < 0 || v >= n || g[u][v] != '.') continue;
    if (vis[u][v]) continue;
    dfs(u, v, col);
  }
}
int now = 0;
int cnt[maxn * maxm + 5];
int in[maxn + 5][maxn + 5];
inline void add_lat(int first, int second, int ty) {
  if (first < 0 || first >= n || second < 0 || second >= n) return;
  in[first][second] += ty;
  if (g[first][second] == '.') {
    int tmp = bel[first][second];
    if (cnt[tmp]) now -= sz[tmp];
    cnt[tmp] += ty;
    if (cnt[tmp]) now += sz[tmp];
  }
}
inline void add_col(int u, int l, int r, int ty) {
  if (u < 0 || u >= n) return;
  for (int i = (l), _end_ = (r); i < _end_; ++i)
    if (i >= 0 && i < n) add_lat(u, i, ty);
}
int main() {
  scanf("%d%d", &n, &K);
  for (int i = (0), _end_ = (n); i < _end_; ++i) scanf("%s", g[i]);
  for (int i = (0), _end_ = (n); i < _end_; ++i)
    for (int j = (0), _end_ = (n); j < _end_; ++j)
      if (g[i][j] == '.' && !vis[i][j]) dfs(i, j, N++);
  int ans = 0;
  for (int i = (0), _end_ = (n - K + 1); i < _end_; ++i) {
    now = 0;
    memset(in, 0, sizeof in);
    memset(cnt, 0, sizeof cnt);
    for (int j = (0), _end_ = (K); j < _end_; ++j) {
      add_col(j, i - 1, i + K + 1, 1);
      for (int k = (i), _end_ = (i + K); k < _end_; ++k)
        if (g[j][k] != '.') ++now;
    }
    for (int j = (0), _end_ = (n - K + 1); j < _end_; ++j) {
      add_col(j + K, i - 1, i + K + 1, 1);
      add_col(j - 2, i - 1, i + K + 1, -1);
      add_lat(j - 1, i - 1, -1);
      add_lat(j - 1, i + K, -1);
      add_lat(j + K, i - 1, -1);
      add_lat(j + K, i + K, -1);
      chkmax(ans, now);
      if (j + K < n) {
        for (int k = (i), _end_ = (i + K); k < _end_; ++k)
          if (g[j + K][k] != '.') ++now;
        for (int k = (i), _end_ = (i + K); k < _end_; ++k)
          if (g[j][k] != '.') --now;
      }
      add_lat(j - 1, i - 1, 1);
      add_lat(j - 1, i + K, 1);
      add_lat(j + K, i - 1, 1);
      add_lat(j + K, i + K, 1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
