#include <bits/stdc++.h>
using namespace std;
int n, k, a[505][505], used[505][505], t = 0, m[250001], ans;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
void dfs(int x, int y, int ks) {
  used[x][y] = 1;
  a[x][y] = ks;
  m[ks]++;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx >= 1 && nx <= n && ny >= 1 && ny <= n && !used[nx][ny] &&
        a[nx][ny] != 0)
      dfs(nx, ny, ks);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      char c;
      cin >> c;
      if (c == '.') a[i][j] = 1;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (!used[i][j] && a[i][j]) {
        t++;
        dfs(i, j, t);
      }
  for (int i = 1; i <= n - k + 1; i++) {
    int s, p, b[300000];
    s = 0;
    p = 0;
    for (int j = 0; j <= n * n; j++) b[j] = 0;
    for (int j = i; j <= i + k - 1; j++)
      for (int l = 1; l <= k; l++) {
        b[a[j][l]]++;
        if (b[a[j][l]] == 1) s += m[a[j][l]];
        if (a[j][l] == 0) p++;
      }
    for (int j = i; j < i + k; j++) {
      b[a[j][k + 1]]++;
      if (b[a[j][k + 1]] == 1) s += m[a[j][k + 1]];
      b[a[j][0]]++;
      if (b[a[j][0]] == 1) s += m[a[j][0]];
    }
    for (int j = 1; j < k + 1; j++) {
      b[a[i + k][j]]++;
      if (b[a[i + k][j]] == 1) s += m[a[i + k][j]];
      b[a[i - 1][j]]++;
      if (b[a[i - 1][j]] == 1) s += m[a[i - 1][j]];
    }
    ans = max(ans, s + p);
    for (int J = 1; J <= n - k; J++) {
      for (int j = i; j < i + k; j++) {
        b[a[j][k + 1 + J - 1]]--;
        if (b[a[j][k + 1 + J - 1]] == 0) s -= m[a[j][k + 1 + J - 1]];
        b[a[j][0 + J - 1]]--;
        if (b[a[j][0 + J - 1]] == 0) s -= m[a[j][0 + J - 1]];
      }
      for (int j = 1; j < k + 1; j++) {
        b[a[i + k][j + J - 1]]--;
        if (b[a[i + k][j + J - 1]] == 0) s -= m[a[i + k][j + J - 1]];
        b[a[i - 1][j + J - 1]]--;
        if (b[a[i - 1][j + J - 1]] == 0) s -= m[a[i - 1][j + J - 1]];
      }
      for (int j = i; j < i + k; j++) {
        b[a[j][k + J]]++;
        if (b[a[j][k + J]] == 1) s += m[a[j][k + J]];
        if (a[j][k + J] == 0) p++;
      }
      for (int j = i; j < i + k; j++) {
        b[a[j][J]]--;
        if (b[a[j][J]] == 0) s -= m[a[j][J]];
        if (a[j][J] == 0) p--;
      }
      for (int j = i; j < i + k; j++) {
        b[a[j][k + 1 + J]]++;
        if (b[a[j][k + 1 + J]] == 1) s += m[a[j][k + 1 + J]];
        b[a[j][0 + J]]++;
        if (b[a[j][0 + J]] == 1) s += m[a[j][0 + J]];
      }
      for (int j = 1; j < k + 1; j++) {
        b[a[i + k][j + J]]++;
        if (b[a[i + k][j + J]] == 1) s += m[a[i + k][j + J]];
        b[a[i - 1][j + J]]++;
        if (b[a[i - 1][j + J]] == 1) s += m[a[i - 1][j + J]];
      }
      ans = max(ans, s + p);
    }
  }
  cout << ans;
}
