#include <bits/stdc++.h>
using namespace std;
using coords = pair<int, int>;
inline void add_neighbours(coords& c, stack<coords>& st, int max,
                           vector<string>& mapa,
                           vector<vector<int> >& components_belonging) {
  if ((c.first != 0) && (mapa[c.first - 1][c.second] == '.') &&
      (components_belonging[c.first - 1][c.second] == 0))
    st.push(make_pair(c.first - 1, c.second));
  if ((c.second != 0) && (mapa[c.first][c.second - 1] == '.') &&
      (components_belonging[c.first][c.second - 1] == 0))
    st.push(make_pair(c.first, c.second - 1));
  if ((c.second != max) && (mapa[c.first][c.second + 1] == '.') &&
      (components_belonging[c.first][c.second + 1] == 0))
    st.push(make_pair(c.first, c.second + 1));
  if ((c.first != max) && (mapa[c.first + 1][c.second] == '.') &&
      (components_belonging[c.first + 1][c.second] == 0))
    st.push(make_pair(c.first + 1, c.second));
}
void collect_components(vector<string>& m,
                        vector<vector<int> >& components_belonging,
                        vector<int>& components) {
  size_t n = components_belonging.size();
  int last_comp = 1;
  int cur_comp_size = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if ((components_belonging[i][j] == 0) && (m[i][j] == '.')) {
        stack<coords> st;
        st.push(make_pair(i, j));
        while (!st.empty()) {
          coords curr = st.top();
          st.pop();
          if (components_belonging[curr.first][curr.second] == 0) {
            components_belonging[curr.first][curr.second] = last_comp;
            cur_comp_size++;
            add_neighbours(curr, st, n - 1, m, components_belonging);
          }
        }
        components[last_comp] = cur_comp_size;
        last_comp++;
        cur_comp_size = 0;
      }
    }
}
inline bool inside(int number, int max) {
  return ((number >= 0) && (number <= max));
}
int get_neighbouring_componenets_sizes(int x, int y,
                                       vector<vector<int> >& field_comp,
                                       vector<int>& components_touching, int k,
                                       int max, int now,
                                       vector<int>& components_sizes) {
  int res = 0;
  bool left, top, right, bottom;
  left = (x - 1 >= 0);
  top = (y - 1 >= 0);
  right = ((x + k) <= max);
  bottom = ((y + k) <= max);
  for (int i = 0; i < k; ++i) {
    if ((left) && (y + i <= max)) {
      int comp_left = field_comp[x - 1][y + i];
      if ((comp_left != 0) && (components_touching[comp_left] != now)) {
        components_touching[comp_left] = now;
        res += components_sizes[comp_left];
      }
    }
    if ((top) && (x + i <= max)) {
      int comp_top = field_comp[x + i][y - 1];
      if ((comp_top != 0) && (components_touching[comp_top] != now)) {
        components_touching[comp_top] = now;
        res += components_sizes[comp_top];
      }
    }
    if ((right) && (y + i <= max)) {
      int comp_right = field_comp[x + k][y + i];
      if ((comp_right != 0) && (components_touching[comp_right] != now)) {
        components_touching[comp_right] = now;
        res += components_sizes[comp_right];
      }
    }
    if ((bottom) && (x + i <= max)) {
      int comp_bottom = field_comp[x + i][y + k];
      if ((comp_bottom != 0) && (components_touching[comp_bottom] != now)) {
        components_touching[comp_bottom] = now;
        res += components_sizes[comp_bottom];
      }
    }
  }
  return res;
}
void find_points_in_square(int row_start, vector<vector<int> >& field_comp,
                           int k, int max, vector<int>& components_sizes) {
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < k; ++j)
      if (inside(row_start + i, max)) {
        int comp = field_comp[row_start + i][j];
        if (comp != 0) components_sizes[comp]--;
      }
}
void move_square_right(int x, int y, vector<vector<int> >& field_comp, int k,
                       int max, vector<int>& components_sizes) {
  for (int i = 0; i < k; ++i) {
    if (inside(y + k - 1, max)) {
      int comp_leave = field_comp[x + i][y - 1];
      if (comp_leave != 0) components_sizes[comp_leave]++;
    }
    if (inside(x + i, max)) {
      int comp_new = field_comp[x + i][y + k - 1];
      if (comp_new != 0) components_sizes[comp_new]--;
    }
  }
}
void move_square_up(int x, int y, vector<vector<int> >& field_comp, int k,
                    int max, vector<int>& components_sizes) {
  for (int i = 0; i < k; ++i) {
    int comp_leave = field_comp[x - 1][y + i];
    if (comp_leave != 0) components_sizes[comp_leave]++;
    int comp_new = field_comp[x + k - 1][y + i];
    if (comp_new != 0) components_sizes[comp_new]--;
  }
}
void move_square_left(int x, int y, vector<vector<int> >& field_comp, int k,
                      int max, vector<int>& components_sizes) {
  for (int i = 0; i < k; ++i) {
    int comp_new = field_comp[x + i][y - 1];
    if (comp_new != 0) components_sizes[comp_new]--;
    int comp_leave = field_comp[x + i][y + k - 1];
    if (comp_leave != 0) components_sizes[comp_leave]++;
  }
}
void leave_row(int x, int y, vector<vector<int> >& field_comp, int k, int max,
               vector<int>& components_sizes) {
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < k; ++j)
      if ((inside(x + i, max)) && (inside(y + j, max))) {
        int comp = field_comp[x + i][y + j];
        if (comp != 0) components_sizes[comp]++;
      }
}
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<string> dungeon;
  dungeon.resize(n);
  for (int i = 0; i < n; ++i) cin >> dungeon[i];
  vector<vector<int> > field_comp;
  field_comp.resize(n);
  for (int i = 0; i < n; ++i) {
    field_comp[i].resize(n);
    for (int j = 0; j < n; ++j) field_comp[i][j] = 0;
  }
  vector<int> components;
  components.resize(n * n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) components[i * n + j] = 0;
  components[0] = 0;
  collect_components(dungeon, field_comp, components);
  int best_answer = 0;
  vector<int> comps_t;
  comps_t.resize(n * n);
  for (int i = 0; i < n * n; ++i) comps_t[i] = -1;
  for (int i = 0; i <= n - k; ++i) {
    if (i == 0)
      find_points_in_square(i, field_comp, k, n - 1, components);
    else
      move_square_up(i, 0, field_comp, k, n - 1, components);
    for (int j = 0; j <= n - k; ++j) {
      int current_size = k * k;
      if (j > 0) move_square_right(i, j, field_comp, k, n - 1, components);
      current_size += get_neighbouring_componenets_sizes(
          i, j, field_comp, comps_t, k, n - 1, i * n + j, components);
      if (current_size > best_answer) best_answer = current_size;
    }
    i++;
    if (i <= n - k) {
      move_square_up(i, n - k, field_comp, k, n - 1, components);
      for (int j = n - k; j >= 0; --j) {
        int current_size = k * k;
        if (j < n - k)
          move_square_left(i, j + 1, field_comp, k, n - 1, components);
        current_size += get_neighbouring_componenets_sizes(
            i, j, field_comp, comps_t, k, n - 1, i * n + j, components);
        if (current_size > best_answer) best_answer = current_size;
      }
    }
  }
  cout << best_answer << endl;
  return 0;
}
