#include <bits/stdc++.h>
using namespace std;
int n, k, cur_component;
bool free_cell[500][500];
int cc[500][500];
int component_size[250000];
bool used_component[250000];
vector<int> used_components;
void dfs(int r, int c) {
  if (r < 0 || r >= n) return;
  if (c < 0 || c >= n) return;
  if (!free_cell[r][c] || cc[r][c]) return;
  cc[r][c] = cur_component;
  component_size[cur_component]++;
  dfs(r - 1, c);
  dfs(r + 1, c);
  dfs(r, c - 1);
  dfs(r, c + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> k;
  for (int r = 0; r < n; r++)
    for (int c = 0; c < n; c++) {
      char symbol;
      cin >> symbol;
      free_cell[r][c] = symbol == '.';
    }
  for (int r = 0; r < n; r++)
    for (int c = 0; c < n; c++)
      if (free_cell[r][c] && !cc[r][c]) {
        cur_component++;
        dfs(r, c);
      }
  for (int r = 0; r < k; r++)
    for (int c = 0; c < k; c++)
      if (free_cell[r][c]) component_size[cc[r][c]]--;
  int max_size = 0;
  for (int r0 = 0, c0 = 0, dir = 1; r0 + k <= n; r0++, dir = -dir) {
    for (; c0 + k <= n && c0 >= 0; c0 += dir) {
      int cur_size = k * k;
      for (int r : {r0 - 1, r0 + k})
        if (r >= 0 && r < n)
          for (int c = c0, i = 0; i < k; c++, i++)
            if (free_cell[r][c] && !used_component[cc[r][c]]) {
              used_component[cc[r][c]] = true;
              used_components.push_back(cc[r][c]);
              cur_size += component_size[cc[r][c]];
            }
      for (int c : {c0 - 1, c0 + k})
        if (c >= 0 && c < n)
          for (int r = r0, i = 0; i < k; r++, i++)
            if (free_cell[r][c] && !used_component[cc[r][c]]) {
              used_component[cc[r][c]] = true;
              used_components.push_back(cc[r][c]);
              cur_size += component_size[cc[r][c]];
            }
      max_size = max(max_size, cur_size);
      for (int component : used_components) used_component[component] = false;
      used_components.clear();
      if (dir > 0 && c0 + k < n)
        for (int r = r0, i = 0; i < k; r++, i++) {
          if (free_cell[r][c0]) component_size[cc[r][c0]]++;
          if (free_cell[r][c0 + k]) component_size[cc[r][c0 + k]]--;
        }
      if (dir < 0 && c0 > 0)
        for (int r = r0, i = 0; i < k; r++, i++) {
          if (free_cell[r][c0 + k - 1]) component_size[cc[r][c0 + k - 1]]++;
          if (free_cell[r][c0 - 1]) component_size[cc[r][c0 - 1]]--;
        }
    }
    c0 = dir > 0 ? n - k : 0;
    for (int c = c0, i = 0; i < k; c++, i++)
      if (free_cell[r0][c]) component_size[cc[r0][c]]++;
    if (r0 + k < n)
      for (int c = c0, i = 0; i < k; c++, i++)
        if (free_cell[r0 + k][c]) component_size[cc[r0 + k][c]]--;
  }
  cout << max_size;
}
