#include <bits/stdc++.h>
const int oo = 0x3f3f3f3f;
template <typename T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <typename T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <typename T>
T read(T &first) {
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (first = 0; isdigit(ch); ch = getchar()) first = 10 * first + ch - '0';
  return first *= f;
}
template <typename T>
void write(T first) {
  if (first == 0) {
    putchar('0');
    return;
  }
  if (first < 0) {
    putchar('-');
    first = -first;
  }
  static char s[20];
  int top = 0;
  for (; first; first /= 10) s[++top] = first % 10 + '0';
  while (top) putchar(s[top--]);
}
const int MAXN = 5e2 + 5;
const int DX[4] = {-1, 0, +1, 0};
const int DY[4] = {0, -1, 0, +1};
int N, K;
int A[MAXN][MAXN];
int tot, size[MAXN * MAXN];
void bfs(std::pair<int, int> s, int id) {
  static std::pair<int, int> q[MAXN * MAXN];
  int front = 0, rear = 0;
  A[s.first][s.second] = id;
  q[rear++] = s;
  while (front != rear) {
    std::pair<int, int> u = q[front++];
    for (int i = 0; i < 4; ++i) {
      std::pair<int, int> v = std::make_pair(u.first + DX[i], u.second + DY[i]);
      int &t = A[v.first][v.second];
      if (t > 1 && t != id) {
        t = id;
        q[rear++] = v;
      }
    }
  }
  size[id] = rear;
}
void input() {
  read(N);
  read(K);
  for (int i = 1; i <= N; ++i) {
    static char inp[MAXN];
    scanf("%s", inp);
    for (int j = 1; j <= N; ++j) {
      A[i][j] = inp[j - 1] == '.' ? +oo : 1;
    }
  }
}
void solve() {
  tot = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      if (A[i][j] == +oo) bfs(std::make_pair(i, j), ++tot);
    }
  }
  static int cnt[MAXN * MAXN];
  static bool flag[MAXN * MAXN];
  int bnd = N - K + 1;
  int ans = 0;
  for (int i = 1; i <= bnd; ++i) {
    memset(cnt, 0, sizeof(cnt));
    memset(flag, 0, sizeof(flag));
    int cur = 0;
    for (int j = 0; j < K; ++j) {
      for (int k = 0; k < K; ++k) {
        do {
          if (cnt[A[i + j][k]]++ == 0) cur += size[A[i + j][k]];
        } while (0);
      }
    }
    for (int j = 1; j <= bnd; ++j) {
      for (int k = 0; k < K; ++k) {
        do {
          if (--cnt[A[i + k][j - 1]] == 0) cur -= size[A[i + k][j - 1]];
        } while (0);
        do {
          if (cnt[A[i + k][j + K - 1]]++ == 0) cur += size[A[i + k][j + K - 1]];
        } while (0);
      }
      for (int k = 0; k < K; ++k) {
        if (A[i - 1][j + k] > 1) do {
            if (cnt[A[i - 1][j + k]]++ == 0) cur += size[A[i - 1][j + k]];
          } while (0);
        if (A[i + k][j - 1] > 1) do {
            if (cnt[A[i + k][j - 1]]++ == 0) cur += size[A[i + k][j - 1]];
          } while (0);
        if (A[i + K][j + k] > 1) do {
            if (cnt[A[i + K][j + k]]++ == 0) cur += size[A[i + K][j + k]];
          } while (0);
        if (A[i + k][j + K] > 1) do {
            if (cnt[A[i + k][j + K]]++ == 0) cur += size[A[i + k][j + K]];
          } while (0);
      }
      chkmax(ans, cur + cnt[1]);
      for (int k = 0; k < K; ++k) {
        if (A[i - 1][j + k] > 1) do {
            if (--cnt[A[i - 1][j + k]] == 0) cur -= size[A[i - 1][j + k]];
          } while (0);
        if (A[i + k][j - 1] > 1) do {
            if (--cnt[A[i + k][j - 1]] == 0) cur -= size[A[i + k][j - 1]];
          } while (0);
        if (A[i + K][j + k] > 1) do {
            if (--cnt[A[i + K][j + k]] == 0) cur -= size[A[i + K][j + k]];
          } while (0);
        if (A[i + k][j + K] > 1) do {
            if (--cnt[A[i + k][j + K]] == 0) cur -= size[A[i + k][j + K]];
          } while (0);
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  input();
  solve();
  return 0;
}
