#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
int n, k;
string graph[MAX_N];
int m, belongs[MAX_N][MAX_N];
int cnt[MAX_N * MAX_N], add_time[MAX_N * MAX_N];
bool inside(int x, int y) { return min(x, y) >= 0 && max(x, y) < n; }
void dfs(int x, int y, int sign) {
  belongs[x][y] = sign;
  ++cnt[sign];
  for (int i = 0; i < 4; ++i) {
    int u = x + dx[i];
    int v = y + dy[i];
    if (inside(u, v) && graph[u][v] == '.' && belongs[u][v] == -1) {
      dfs(u, v, sign);
    }
  }
}
void add(int x, int y, int& cur, int cur_time) {
  if (inside(x, y) && graph[x][y] == '.' &&
      add_time[belongs[x][y]] != cur_time) {
    add_time[belongs[x][y]] = cur_time;
    cur += cnt[belongs[x][y]];
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> graph[i];
  }
  memset(belongs, 0xFF, sizeof(belongs));
  m = 0;
  memset(cnt, 0x00, sizeof(cnt));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (graph[i][j] == '.' && belongs[i][j] == -1) {
        dfs(i, j, m++);
      }
    }
  }
  memset(add_time, 0x00, sizeof(add_time));
  int cur_time = 0, res = 0;
  for (int y_low = 0; y_low <= n - k; ++y_low) {
    for (int i = 0; i < k; ++i) {
      for (int j = y_low; j < y_low + k; ++j) {
        if (graph[i][j] == '.') {
          --cnt[belongs[i][j]];
        }
      }
    }
    for (int x_low = 0; x_low <= n - k; ++x_low) {
      ++cur_time;
      int cur = k * k;
      for (int i = 0; i < k; ++i) {
        add(x_low - 1, y_low + i, cur, cur_time);
        add(x_low + k, y_low + i, cur, cur_time);
        add(x_low + i, y_low - 1, cur, cur_time);
        add(x_low + i, y_low + k, cur, cur_time);
      }
      res = max(res, cur);
      if (x_low != n - k) {
        for (int i = 0; i < k; ++i) {
          if (graph[x_low][y_low + i] == '.') {
            ++cnt[belongs[x_low][y_low + i]];
          }
          if (graph[x_low + k][y_low + i] == '.') {
            --cnt[belongs[x_low + k][y_low + i]];
          }
        }
      }
    }
    for (int i = n - k; i < n; ++i) {
      for (int j = y_low; j < y_low + k; ++j) {
        if (graph[i][j] == '.') {
          ++cnt[belongs[i][j]];
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
