#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int M = 510;
char A[M][M];
int visited[M][M], cnt[M * M], taken[M * M], N, K, xvis[M][M];
int dfs(int first, int second, int c) {
  visited[first][second] = c;
  int sum = 0;
  for (int i = 0; i < 4; i++) {
    int x1 = first + dx[i], y1 = second + dy[i];
    if (!((x1) >= 0 && (x1) < N && (y1) >= 0 && (y1) < N) || visited[x1][y1] ||
        A[x1][y1] == 'X')
      continue;
    sum += dfs(x1, y1, c);
  }
  return sum + 1;
}
int take(int first, int second, int inside) {
  if (xvis[first][second]) return 0;
  xvis[first][second] = true;
  int c = visited[first][second];
  if (c == 0) return inside;
  taken[c]++;
  if (taken[c] > 1) return 0;
  return cnt[c];
}
int main() {
  int i, j, k, maxx = 0, temp, c = 0;
  scanf("%d%d", &N, &K);
  for (i = 0; i < N; i++) scanf("%s", A[i]);
  memset((visited), (0), sizeof(visited));
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      if (A[i][j] == '.' && !visited[i][j]) {
        c++;
        cnt[c] = dfs(i, j, c);
      }
    }
  }
  memset((taken), (0), sizeof(taken));
  for (int r1 = 0, r2 = K - 1; r2 < N; r1++, r2++) {
    temp = 0;
    memset((taken), (0), sizeof(taken));
    memset((xvis), (false), sizeof(xvis));
    for (int c1 = 0, c2 = K - 1; c2 < N; c1++, c2++) {
      if (c1 == 0) {
        for (i = r1; i <= r2; i++)
          for (j = c1; j <= c2; j++) temp += take(i, j, 1);
      } else {
        for (i = r1; i <= r2; i++)
          if (visited[i][c2] == 0) temp++;
        for (i = r1; i <= r2; i++)
          if (visited[i][c1 - 1] == 0) temp--;
      }
      if (r1 > 0)
        for (i = c1; i <= c2; i++) temp += take(r1 - 1, i, 0);
      if (r2 < N - 1)
        for (i = c1; i <= c2; i++) temp += take(r2 + 1, i, 0);
      if (c1 > 0)
        for (i = r1; i <= r2; i++) temp += take(i, c1 - 1, 0);
      if (c2 < N - 1)
        for (i = r1; i <= r2; i++) temp += take(i, c2 + 1, 0);
      if (c1 > 1) {
        for (i = r1; i <= r2; i++) {
          int cc = visited[i][c1 - 2];
          if (cc) {
            taken[cc]--;
            if (taken[cc] == 0) temp -= cnt[cc];
          }
        }
      }
      if (c1 > 0) {
        int cc = visited[r2 + 1][c1 - 1];
        if (cc) {
          taken[cc]--;
          if (taken[cc] == 0) temp -= cnt[cc];
        }
        if (r1 - 1 >= 0) {
          cc = visited[r1 - 1][c1 - 1];
          if (cc) {
            taken[cc]--;
            if (taken[cc] == 0) temp -= cnt[cc];
          }
        }
      }
      maxx = max(maxx, temp);
    }
  }
  printf("%d\n", maxx);
  return 0;
}
