#include <bits/stdc++.h>
using namespace std;
bool v[505][505], vis[505][505];
int size[505][505], ans[505][505], cc[505][505], cc_size[505 * 505],
    addtime[505 * 505];
int temp, temp2;
int n, k;
void bfs(int x, int y) {
  temp2++;
  cc[x][y] = temp;
  vis[x][y] = true;
  if (!vis[x + 1][y] and v[x + 1][y]) bfs(x + 1, y);
  if (!vis[x - 1][y] and v[x - 1][y]) bfs(x - 1, y);
  if (!vis[x][y + 1] and v[x][y + 1]) bfs(x, y + 1);
  if (!vis[x][y - 1] and v[x][y - 1]) bfs(x, y - 1);
}
void add(int x, int y, int& answer, int current_time) {
  if (v[x][y]) {
    int id = cc[x][y];
    if (addtime[id] != current_time) {
      addtime[id] = current_time;
      answer += cc_size[id];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int precision = numeric_limits<double>::digits10;
  cout << setprecision(precision);
  cin >> n >> k;
  char c;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> c;
      c == '.' ? v[i + 1][j + 1] = true : v[i + 1][j + 1] = false;
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!vis[i + 1][j + 1] && v[i + 1][j + 1]) {
        temp++;
        temp2 = 0;
        bfs(i + 1, j + 1);
        cc_size[temp] = temp2;
      }
    }
  }
  int cur = 1;
  int best_answer = 0;
  for (int y = 1; y <= n - k + 1; y++) {
    for (int i = 1; i < k + 1; i++) {
      for (int j = y; j < y + k; j++) {
        if (v[i][j]) cc_size[cc[i][j]]--;
      }
    }
    for (int i = 1; i < n - k + 2; i++) {
      int answer = k * k;
      for (int j = y; j < y + k; j++) add(i - 1, j, answer, cur);
      for (int j = y; j < y + k; j++) add(i + k, j, answer, cur);
      for (int x = i; x < i + k; x++) add(x, y - 1, answer, cur);
      for (int x = i; x < i + k; x++) add(x, y + k, answer, cur);
      cur++;
      best_answer = max(best_answer, answer);
      if (i != n - k + 1)
        for (int j = y; j < y + k; j++) cc_size[cc[i + k][j]]--;
      if (i != n - k + 1)
        for (int j = y; j < y + k; j++) cc_size[cc[i][j]]++;
    }
    for (int x = n - k + 1; x <= n; ++x)
      for (int j = y; j < y + k; ++j) ++cc_size[cc[x][j]];
  }
  cout << best_answer;
}
