#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& a) {
  a = 0;
  char c;
  bool f = 0;
  while (!isdigit(c = getchar()))
    if (c == '-') f = 1;
  do a = a * 10 + c - '0';
  while (isdigit(c = getchar()));
  if (f) a = -a;
}
const int INF = 0x7fffffff;
const long double eps = 1e-8;
const long long MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int MAXN = 502;
int N, K;
int fa[MAXN * MAXN], sz[MAXN * MAXN];
int F[MAXN][MAXN];
int A[MAXN][MAXN], sum[MAXN][MAXN];
int getid(int x, int y) { return (x - 1) * N + y; }
int getf(int x) {
  if (fa[x] == x) return x;
  return fa[x] = getf(fa[x]);
}
void merge(int x, int y) {
  x = getf(x);
  y = getf(y);
  if (x == y) return;
  if (sz[x] > sz[y]) swap(x, y);
  fa[x] = y;
  sz[y] += sz[x];
}
int V[MAXN * MAXN];
char st[MAXN][MAXN];
int main(int argc, char* argv[]) {
  read(N);
  read(K);
  for (int i = 1; i <= N; ++i) scanf("%s", st[i] + 1);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j) A[i][j] = st[i][j] == '.';
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j)
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + A[i][j];
  for (int i = 1; i <= N * N; ++i) fa[i] = i, sz[i] = 1;
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j)
      for (int d = 0; d <= 3; ++d)
        if (A[i][j] && A[i + dx[d]][j + dy[d]])
          merge(getid(i, j), getid(i + dx[d], j + dy[d]));
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j) F[i][j] = getf(getid(i, j));
  int ans = 0;
  for (int i = 1; i <= N - K + 1; ++i) {
    int tot = 0;
    for (int j = 1; j <= N * N; ++j) V[j] = 0;
    for (int di = -1; di <= K; ++di)
      for (int j = 0; j <= K + 1; ++j)
        if ((!((di == -1 || di == K) && (j == 0 || j == K + 1))) &&
            A[i + di][j])
          if (++V[F[i + di][j]] == 1) tot += sz[F[i + di][j]];
    for (int j = 1; j <= N - K + 1; ++j) {
      if (j != 1) {
        for (int di = -1; di <= K; ++di) {
          int tj = di == -1 || di == K ? j - 1 : j - 2;
          int ti = i + di;
          if (A[ti][tj])
            if (--V[F[ti][tj]] == 0) tot -= sz[F[ti][tj]];
        }
        for (int di = -1; di <= K; ++di) {
          int tj = di == -1 || di == K ? j + K - 1 : j + K;
          int ti = i + di;
          if (A[ti][tj])
            if (++V[F[ti][tj]] == 1) tot += sz[F[ti][tj]];
        }
      }
      int tans = tot + K * K -
                 (sum[i + K - 1][j + K - 1] + sum[i - 1][j - 1] -
                  sum[i - 1][j + K - 1] - sum[i + K - 1][j - 1]);
      ((ans) = max(ans, tans));
    }
  }
  printf("%d\n", ans);
  return 0;
}
