#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class A, class B, class C>
struct Triple {
  A first;
  B second;
  C third;
  bool operator<(const Triple& t) const {
    if (first != t.first) return first < t.first;
    if (second != t.second) return second < t.second;
    return third < t.third;
  }
};
template <class T>
void ResizeVec(T&, vector<long long>) {}
template <class T>
void ResizeVec(vector<T>& vec, vector<long long> sz) {
  vec.resize(sz[0]);
  sz.erase(sz.begin());
  if (sz.empty()) {
    return;
  }
  for (T& v : vec) {
    ResizeVec(v, sz);
  }
}
template <class A, class B, class C>
ostream& operator<<(ostream& out, Triple<A, B, C> t) {
  return out << "(" << t.first << ", " << t.second << ", " << t.third << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
const long long N = 5e2 + 5;
long long sz_comp[N * N];
long long cnt_comp[N * N];
long long wh_cc[N][N];
long long board[N][N];
long long dr[] = {1, -1, 0, 0};
long long dc[] = {0, 0, 1, -1};
long long n;
bool OnBoard(long long r, long long c) {
  return r >= 1 && r <= n && c >= 1 && c <= n;
}
long long Dfs(long long r, long long c, long long heh) {
  wh_cc[r][c] = heh;
  long long sz = 1;
  for (long long dir = 0; dir < (4); ++dir) {
    long long nr = r + dr[dir];
    long long nc = c + dc[dir];
    if (OnBoard(nr, nc) && wh_cc[nr][nc] == 0 && board[nr][nc] == 1) {
      sz += Dfs(nr, nc, heh);
    }
  }
  return sz;
}
long long cur;
void UpdField(long long r, long long c, long long sign, long long inside) {
  if (!OnBoard(r, c)) {
    return;
  }
  if (board[r][c] == 0) {
    if (inside) {
      cur += sign;
    }
    return;
  }
  long long comp = wh_cc[r][c];
  if (cnt_comp[comp]) {
    cur -= sz_comp[comp];
  }
  cnt_comp[comp] += sign;
  if (cnt_comp[comp]) {
    cur += sz_comp[comp];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  if (0) cout << fixed << setprecision(10);
  cin.tie(0);
  long long k;
  cin >> n >> k;
  for (long long i = (1); i <= (n); ++i) {
    for (long long j = (1); j <= (n); ++j) {
      char c;
      cin >> c;
      if (c == '.') {
        board[i][j] = 1;
      }
    }
  }
  long long nxt_c = 1;
  for (long long i = (1); i <= (n); ++i) {
    for (long long j = (1); j <= (n); ++j) {
      if (board[i][j] && wh_cc[i][j] == 0) {
        sz_comp[nxt_c] = Dfs(i, j, nxt_c);
        nxt_c++;
      }
      if (0) cout << wh_cc[i][j];
    }
    if (0) cout << endl;
  }
  long long best = 0;
  for (long long r = (1); r <= (n - k + 1); ++r) {
    for (long long c = (1); c <= (n - k + 1); ++c) {
      if (c == 1) {
        for (long long rr = (r); rr <= (r + k - 1); ++rr) {
          for (long long cc = (c); cc <= (c + k - 1); ++cc) {
            UpdField(rr, cc, 1, 1);
            if (rr == r) {
              UpdField(rr - 1, cc, 1, 0);
              UpdField(rr + k, cc, 1, 0);
            }
          }
          UpdField(rr, c + k, 1, 0);
        }
      } else {
        for (long long rr = (r); rr <= (r + k - 1); ++rr) {
          UpdField(rr, c + k - 1, -1, 0);
          UpdField(rr, c + k - 1, 1, 1);
          UpdField(rr, c - 1, -1, 1);
          UpdField(rr, c - 1, 1, 0);
          UpdField(rr, c + k, 1, 0);
          UpdField(rr, c - 2, -1, 0);
        }
        UpdField(r - 1, c - 1, -1, 0);
        UpdField(r + k, c - 1, -1, 0);
        UpdField(r - 1, c + k - 1, 1, 0);
        UpdField(r + k, c + k - 1, 1, 0);
      }
      maxi(best, cur);
      (r, c, cur);
    }
    for (long long i = (1); i <= (n * n); ++i) {
      cnt_comp[i] = 0;
    }
    cur = 0;
  }
  cout << best << endl;
  return 0;
}
