#include <bits/stdc++.h>
using namespace std;
const int N = 503;
int n, k;
char str[N][N];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int reprx[N][N];
int repry[N][N];
int used[N][N];
int sz[N][N];
int good(int x, int y) { return 0 <= x && x < n && 0 <= y && y < n; }
void dfs(int x, int y, int a, int b) {
  used[x][y] = 1;
  reprx[x][y] = a;
  repry[x][y] = b;
  sz[x][y] = 1;
  for (int(k) = (0); !((k) == (4)); (4) > (0) ? (k)++ : (k)--) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if (good(nx, ny) && !used[nx][ny] && str[nx][ny] == '.') {
      dfs(nx, ny, a, b);
      sz[x][y] += sz[nx][ny];
    }
  }
}
int size(int x, int y) {
  int a = reprx[x][y];
  int b = repry[x][y];
  return sz[a][b];
}
int s[N][N];
int compx[N * N];
int compy[N * N];
int comps;
int Size(int x, int y) {
  int a = reprx[x][y];
  int b = repry[x][y];
  return sz[a][b];
}
template <class T>
void for_all(int x1, int y1, int x2, int y2, T op) {
  for (int(i) = (y1); !((i) == (y2 + 1)); (y2 + 1) > (y1) ? (i)++ : (i)--) {
    if (good(x1 - 1, i)) {
      op(x1 - 1, i);
    }
    if (good(x2 + 1, i)) {
      op(x2 + 1, i);
    }
  }
  for (int(i) = (x1); !((i) == (x2 + 1)); (x2 + 1) > (x1) ? (i)++ : (i)--) {
    if (good(i, y1 - 1)) {
      op(i, y1 - 1);
    }
    if (good(i, y2 + 1)) {
      op(i, y2 + 1);
    }
  }
}
int currx, curry;
int inside[N][N];
int ans;
int answer;
void getr(int x, int y, int& a, int& b) {
  a = reprx[x][y];
  b = repry[x][y];
}
void right() {
  int ex = currx + k - 1;
  int ey = curry + k - 1;
  for (int(i) = (currx); !((i) == (ex + 1));
       (ex + 1) > (currx) ? (i)++ : (i)--) {
    if (str[i][curry] == '.') {
      int a, b;
      getr(i, curry, a, b);
      inside[a][b]--;
    }
    if (good(i, ey + 1)) {
      if (str[i][ey + 1] == '.') {
        int a, b;
        getr(i, ey + 1, a, b);
        inside[a][b]++;
      }
    }
  }
  curry++;
}
void down() {
  int ex = currx + k - 1;
  int ey = curry + k - 1;
  for (int(i) = (curry); !((i) == (ey + 1));
       (ey + 1) > (curry) ? (i)++ : (i)--) {
    if (str[currx][i] == '.') {
      int a, b;
      getr(currx, i, a, b);
      inside[a][b]--;
    }
    if (good(ex + 1, i)) {
      if (str[ex + 1][i] == '.') {
        int a, b;
        getr(ex + 1, i, a, b);
        inside[a][b]++;
      }
    }
  }
  currx++;
}
void left() {
  int ex = currx + k - 1;
  int ey = curry + k - 1;
  for (int(i) = (currx); !((i) == (ex + 1));
       (ex + 1) > (currx) ? (i)++ : (i)--) {
    if (str[i][ey] == '.') {
      int a, b;
      getr(i, ey, a, b);
      inside[a][b]--;
    }
    if (good(i, curry - 1)) {
      if (str[i][curry - 1] == '.') {
        int a, b;
        getr(i, curry - 1, a, b);
        inside[a][b]++;
      }
    }
  }
  curry--;
}
int superused[N][N];
int superptr = 1;
int stuff() {
  int ex = currx + k - 1;
  int ey = curry + k - 1;
  ans = k * k;
  superptr++;
  for_all(currx, curry, ex, ey, [](int a, int b) -> void {
    if (str[a][b] == '.') {
      int ra = reprx[a][b];
      int rb = repry[a][b];
      if (superused[ra][rb] != superptr) {
        superused[ra][rb] = superptr;
        ans += sz[ra][rb] - inside[ra][rb];
      }
    }
  });
  return ans;
}
int save[N][N];
int used2[N][N];
int sz2[N][N];
int dfs2(int x, int y) {
  used2[x][y] = 1;
  sz2[x][y] = 1;
  for (int(k) = (0); !((k) == (4)); (4) > (0) ? (k)++ : (k)--) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if (good(nx, ny) && !used2[nx][ny] && save[nx][ny] == '.') {
      dfs2(nx, ny);
      sz2[x][y] += sz2[nx][ny];
    }
  }
  return sz2[x][y];
}
int brute(int x1, int y1, int x2, int y2) {
  copy(str[0], str[0] + sizeof(str), &save[0][0]);
  for (int(i) = (x1); !((i) == (x2 + 1)); (x2 + 1) > (x1) ? (i)++ : (i)--) {
    for (int(j) = (y1); !((j) == (y2 + 1)); (y2 + 1) > (y1) ? (j)++ : (j)--) {
      save[i][j] = '.';
    }
  }
  fill(used2[0], used2[0] + sizeof(used2) / 4, 0);
  return dfs2(x1, y1);
}
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (int(i) = (0); !((i) == (n)); (n) > (0) ? (i)++ : (i)--) {
    cin >> str[i];
  }
  for (int(i) = (0); !((i) == (n)); (n) > (0) ? (i)++ : (i)--) {
    for (int(j) = (0); !((j) == (n)); (n) > (0) ? (j)++ : (j)--) {
      if (str[i][j] == '.' && !used[i][j]) {
        dfs(i, j, i, j);
        compx[comps] = i;
        compy[comps] = j;
        comps++;
      }
    }
  }
  for (int(i) = (0); !((i) == (k)); (k) > (0) ? (i)++ : (i)--) {
    for (int(j) = (0); !((j) == (k)); (k) > (0) ? (j)++ : (j)--) {
      if (str[i][j] == '.') {
        int a, b;
        getr(i, j, a, b);
        inside[a][b]++;
      }
    }
  }
  int dos = n - k + 1;
  int ans = 0;
  for (int(i) = (0); !((i) == (dos)); (dos) > (0) ? (i)++ : (i)--) {
    for (int(j) = (0); !((j) == (dos)); (dos) > (0) ? (j)++ : (j)--) {
      ans = max(ans, stuff());
      if (i % 2 == 0) {
        if (j == dos - 1) {
          down();
        } else {
          right();
        }
      } else {
        if (j == dos - 1) {
          down();
        } else {
          left();
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
