#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int n, k, cnt = 0, t = 1;
char ch;
bool a[N][N] = {};
int col[N][N] = {};
int sz[N * N] = {};
int m[N * N] = {};
int u[N * N] = {};
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
void dfs(int x, int y) {
  col[x][y] = cnt;
  sz[cnt]++;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (a[nx][ny] && !col[nx][ny]) dfs(nx, ny);
  }
}
void row(int x, int l, int r, int f) {
  for (int i = l; i <= r; i++) {
    if (a[x][i]) m[col[x][i]] += f;
  }
}
void column(int y, int l, int r, int f) {
  for (int i = l; i <= r; i++) {
    if (a[i][y]) m[col[i][y]] += f;
  }
}
int check(int x, int y) {
  if (x + k - 1 > n || y + k - 1 > n) return 0;
  int res = 0, c;
  for (int i = y; i < y + k; i++) {
    c = col[x - 1][i];
    if (a[x - 1][i] && u[c] < t) {
      res += sz[c] - m[c];
      u[c] = t;
    }
    c = col[x + k][i];
    if (a[x + k][i] && u[c] < t) {
      res += sz[c] - m[c];
      u[c] = t;
    }
  }
  for (int i = x; i < x + k; i++) {
    c = col[i][y - 1];
    if (a[i][y - 1] && u[c] < t) {
      res += sz[c] - m[c];
      u[c] = t;
    }
    c = col[i][y + k];
    if (a[i][y + k] && u[c] < t) {
      res += sz[c] - m[c];
      u[c] = t;
    }
  }
  return res;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> ch;
      a[i][j] = (ch == '.');
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] && !col[i][j]) {
        cnt++;
        dfs(i, j);
      }
    }
  }
  int mx = 0;
  for (int i = 1; i <= k; i++) {
    row(i, 1, k, 1);
  }
  mx = max(mx, check(1, 1));
  t++;
  for (int i = 1; i + k - 1 <= n; i++) {
    if (i % 2) {
      for (int j = 1; j + k - 1 < n; j++) {
        column(j, i, i + k - 1, -1);
        column(j + k, i, i + k - 1, 1);
        mx = max(mx, check(i, j + 1));
        t++;
      }
      row(i, n - k + 1, n, -1);
      row(i + k, n - k + 1, n, 1);
      mx = max(mx, check(i + 1, n - k + 1));
      t++;
    } else {
      for (int j = n - k; j >= 1; j--) {
        column(j, i, i + k - 1, 1);
        column(j + k, i, i + k - 1, -1);
        mx = max(mx, check(i, j));
        t++;
      }
      row(i, 1, k, -1);
      row(i + k, 1, k, 1);
      mx = max(mx, check(i + 1, 1));
      t++;
    }
  }
  cout << k * k + mx;
  return 0;
}
