#include <bits/stdc++.h>
using namespace std;
int explore(vector<vector<int>>& map, int r, int c, int id) {
  int size = 1;
  map[r][c] = id;
  if (r > 0 && map[r - 1][c] == -2) {
    size += explore(map, r - 1, c, id);
  }
  if (r < (int)map.size() - 1 && map[r + 1][c] == -2) {
    size += explore(map, r + 1, c, id);
  }
  if (c > 0 && map[r][c - 1] == -2) {
    size += explore(map, r, c - 1, id);
  }
  if (c < (int)map.size() - 1 && map[r][c + 1] == -2) {
    size += explore(map, r, c + 1, id);
  }
  return size;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<vector<int>> map(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      map[i][j] = c == '.' ? -2 : -1;
    }
  }
  int component_id = 0;
  vector<int> component_size;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (map[i][j] == -2) {
        component_size.push_back(explore(map, i, j, component_id++));
      }
    }
  }
  int max_connected = 0;
  for (int i = 0; i + k <= n; ++i) {
    vector<int> inside(component_id, 0);
    for (int p = i; p < i + k; ++p) {
      for (int q = 0; q < k; ++q) {
        if (map[p][q] >= 0) {
          ++inside[map[p][q]];
        }
      }
    }
    vector<bool> connect_help(component_id, false);
    for (int j = 0; j + k <= n; ++j) {
      vector<int> connect;
      for (int p = 0; p < k; ++p) {
        if (i > 0 && map[i - 1][j + p] >= 0 &&
            !connect_help[map[i - 1][j + p]]) {
          connect_help[map[i - 1][j + p]] = true;
          connect.push_back(map[i - 1][j + p]);
        }
        if (i + k < n && map[i + k][j + p] >= 0 &&
            !connect_help[map[i + k][j + p]]) {
          connect_help[map[i + k][j + p]] = true;
          connect.push_back(map[i + k][j + p]);
        }
        if (j > 0 && map[i + p][j - 1] >= 0 &&
            !connect_help[map[i + p][j - 1]]) {
          connect_help[map[i + p][j - 1]] = true;
          connect.push_back(map[i + p][j - 1]);
        }
        if (j + k < n && map[i + p][j + k] >= 0 &&
            !connect_help[map[i + p][j + k]]) {
          connect_help[map[i + p][j + k]] = true;
          connect.push_back(map[i + p][j + k]);
        }
      }
      if (j > 0) {
        for (int p = 0; p < k; ++p) {
          if (map[i + p][j - 1] >= 0) {
            --inside[map[i + p][j - 1]];
          }
          if (map[i + p][j + k - 1] >= 0) {
            ++inside[map[i + p][j + k - 1]];
          }
        }
      }
      int connected = k * k;
      for (int c : connect) {
        connected += component_size[c] - inside[c];
        connect_help[c] = false;
      }
      max_connected = max(max_connected, connected);
    }
  }
  cout << max_connected << endl;
}
