#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, 0, -1, 0};
int fy[] = {0, 1, 0, -1};
int n;
char grid[505][505];
int which_group[505][505], group_size[505 * 505];
bool isInside(int x, int y) { return 0 <= min(x, y) && max(x, y) < n; }
void dfs(int x, int y, int group) {
  which_group[x][y] = group;
  group_size[group]++;
  for (int i = 0; i < 4; i++) {
    int x1 = x + fx[i];
    int y1 = y + fy[i];
    if (isInside(x1, y1) && grid[x1][y1] == '.' && !which_group[x1][y1])
      dfs(x1, y1, group);
  }
}
int time_of_add[505 * 505];
void canAdd(int x, int y, int &adder, int call_time) {
  if (isInside(x, y) && grid[x][y] == '.') {
    int id = which_group[x][y];
    if (time_of_add[id] != call_time) {
      time_of_add[id] = call_time;
      adder += group_size[id];
    }
  }
}
int main() {
  int k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%s", grid[i]);
  int total_group = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (grid[i][j] == '.' && !which_group[i][j]) dfs(i, j, ++total_group);
  int ans = 0, call_time = 1;
  for (int Y = 0; Y + k <= n; Y++) {
    for (int i = 0; i < k; i++)
      for (int j = Y; j < Y + k; j++) --group_size[which_group[i][j]];
    for (int X = 0; X + k <= n; X++) {
      int cur_ans = k * k;
      for (int i = X; i < X + k; i++)
        canAdd(i, Y - 1, cur_ans, call_time),
            canAdd(i, Y + k, cur_ans, call_time);
      for (int j = Y; j < Y + k; j++)
        canAdd(X - 1, j, cur_ans, call_time),
            canAdd(X + k, j, cur_ans, call_time);
      call_time++;
      ans = max(ans, cur_ans);
      if (X + k != n)
        for (int j = Y; j < Y + k; j++)
          ++group_size[which_group[X][j]], --group_size[which_group[X + k][j]];
    }
    for (int i = n - k; i < n; i++)
      for (int j = Y; j < Y + k; j++) ++group_size[which_group[i][j]];
  }
  printf("%d\n", ans);
  return 0;
}
