#include <bits/stdc++.h>
using namespace std;
const int N = 500, K = 500;
string grid[N];
int comp[N][N];
bool vis[N][N];
int comp_num;
vector<int> comp_size;
int comp_cnt[N * N];
vector<int> mask;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int sum = 0;
int n, k;
inline bool in(int x, int y) { return 0 <= x && x < n && 0 <= y && y < n; }
void dfs_com(int x, int y, int c) {
  ++comp_size[c];
  vis[x][y] = true;
  comp[x][y] = c;
  for (int i = 0; i < 4; ++i) {
    int nx = x + dx[i], ny = y + dy[i];
    if (in(nx, ny) && grid[nx][ny] == '.' && !vis[nx][ny]) dfs_com(nx, ny, c);
  }
}
inline void add(int x, int y) {
  if (!in(x, y)) return;
  if (grid[x][y] == '.') {
    ++comp_cnt[comp[x][y]];
    mask.push_back(comp[x][y]);
    if (comp_cnt[comp[x][y]] == 1) sum += comp_size[comp[x][y]];
  } else if (grid[x][y] == 'X') {
    ++sum;
  }
}
inline void del(int x, int y) {
  if (!in(x, y)) return;
  if (grid[x][y] == '.') {
    --comp_cnt[comp[x][y]];
    if (comp_cnt[comp[x][y]] == 0) sum -= comp_size[comp[x][y]];
  } else if (grid[x][y] == 'X') {
    --sum;
  }
}
inline bool is_X(int x, int y) {
  if (!in(x, y)) return true;
  return grid[x][y] == 'X';
}
inline bool is_D(int x, int y) {
  if (!in(x, y)) return true;
  return grid[x][y] == '.';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> grid[i];
  if (k == n) {
    cout << n * n << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!vis[i][j] && grid[i][j] == '.') {
        comp_size.push_back(0);
        dfs_com(i, j, comp_num);
        ans = max(ans, comp_size[comp_num]);
        ++comp_num;
      }
    }
  }
  for (int i = 0; i < n + 1 - k; ++i) {
    for (auto l : mask) comp_cnt[l] = 0;
    mask.clear();
    sum = 0;
    for (int l = i; l < i + k; ++l) {
      if (is_D(l, 0)) add(l, 0);
    }
    for (int j = 0; j < n; ++j) {
      if (is_D(i - 1, j)) add(i - 1, j);
      if (is_D(i + k, j)) add(i + k, j);
      for (int l = i; l < i + k; ++l) {
        if (is_D(l, j + 1)) add(l, j + 1);
        if (is_X(l, j)) add(l, j);
      }
      if (j >= k) {
        for (int l = i; l < i + k; ++l)
          if (is_X(l, j - k)) del(l, j - k);
        if (is_D(i - 1, j - k)) del(i - 1, j - k);
        if (is_D(i + k, j - k)) del(i + k, j - k);
      }
      if (j >= k + 1) {
        for (int l = i; l < i + k; ++l)
          if (is_D(l, j - k - 1)) del(l, j - k - 1);
      }
      ans = max(sum, ans);
    }
  }
  cout << ans << endl;
  return 0;
}
