#include <bits/stdc++.h>
using namespace std;
const int N = 510;
const int N1 = N * N;
int a[N][N], b[N][N];
int n, cnt, idx;
int freq[N1];
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
inline bool ok(int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < n) return true;
  return false;
}
void bfs(int i, int j) {
  queue<pair<int, int> > q;
  q.push(make_pair(i, j));
  b[i][j] = idx;
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    cnt++;
    q.pop();
    for (int k = 0; k < 4; k++) {
      int x = cur.first + dx[k];
      int y = cur.second + dy[k];
      if (!ok(x, y) || a[x][y] == 0 || b[x][y] != 0) continue;
      q.push(make_pair(x, y));
      b[x][y] = idx;
    }
  }
}
int main() {
  int k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    char s[N];
    scanf("%s ", s);
    for (int j = 0; j < n; j++) {
      if (s[j] == '.')
        a[i][j] = 1;
      else
        a[i][j] = 0;
    }
  }
  idx = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == 1 && b[i][j] == 0) {
        cnt = 0;
        bfs(i, j);
        freq[idx] = cnt;
        idx++;
      }
    }
  }
  int ans = -1;
  for (int i = 0; i + k - 1 < n; i++) {
    vector<int> f1(N1);
    int num = 0;
    int block = 0;
    for (int x = i; x <= i + k - 1; x++) {
      for (int y = 0; y <= k - 1; y++) {
        if (!ok(x, y)) continue;
        if (a[x][y] == 0) {
          block++;
          continue;
        }
        f1[b[x][y]]++;
        if (f1[b[x][y]] == 1) num += freq[b[x][y]];
      }
    }
    for (int x = i - 1; x <= i + k; x += k + 1) {
      for (int y = 0; y <= k - 1; y++) {
        if (!ok(x, y)) continue;
        if (a[x][y] == 0) continue;
        f1[b[x][y]]++;
        if (f1[b[x][y]] == 1) num += freq[b[x][y]];
      }
    }
    for (int x = i; x <= i + k - 1; x++) {
      for (int y = k; y <= k; y++) {
        if (!ok(x, y)) continue;
        if (a[x][y] == 0) continue;
        f1[b[x][y]]++;
        if (f1[b[x][y]] == 1) num += freq[b[x][y]];
      }
    }
    for (int j = 0; j + k - 1 < n; j++) {
      ans = max(ans, num + block);
      for (int x = i; x <= i + k - 1; x++) {
        for (int y = j - 1; y <= j - 1; y++) {
          if (!ok(x, y)) continue;
          if (a[x][y] == 0) continue;
          f1[b[x][y]]--;
          if (f1[b[x][y]] == 0) num -= freq[b[x][y]];
        }
      }
      for (int x = i; x <= i + k - 1; x++) {
        for (int y = j; y <= j; y++) {
          if (!ok(x, y)) continue;
          if (a[x][y] == 0) {
            block--;
            continue;
          }
        }
      }
      if (ok(i - 1, j) && a[i - 1][j] == 1) {
        f1[b[i - 1][j]]--;
        if (f1[b[i - 1][j]] == 0) num -= freq[b[i - 1][j]];
      }
      if (ok(i + k, j) && a[i + k][j] == 1) {
        f1[b[i + k][j]]--;
        if (f1[b[i + k][j]] == 0) num -= freq[b[i + k][j]];
      }
      for (int x = i; x <= i + k - 1; x++) {
        for (int y = j + k; y <= j + k; y++) {
          if (!ok(x, y)) continue;
          if (a[x][y] == 0) {
            block++;
            continue;
          }
        }
      }
      if (ok(i - 1, j + k) && a[i - 1][j + k] == 1) {
        f1[b[i - 1][j + k]]++;
        if (f1[b[i - 1][j + k]] == 1) num += freq[b[i - 1][j + k]];
      }
      if (ok(i + k, j + k) && a[i + k][j + k] == 1) {
        f1[b[i + k][j + k]]++;
        if (f1[b[i + k][j + k]] == 1) num += freq[b[i + k][j + k]];
      }
      for (int x = i; x <= i + k - 1; x++) {
        for (int y = j + k + 1; y <= j + k + 1; y++) {
          if (!ok(x, y)) continue;
          if (a[x][y] == 0) continue;
          f1[b[x][y]]++;
          if (f1[b[x][y]] == 1) num += freq[b[x][y]];
        }
      }
    }
  }
  cout << ans << endl;
}
