#include <bits/stdc++.h>
int n, k, p[250001], s[250001], ans, v[250001];
char map[501][501];
inline int find1(int x) {
  return ~p[x] ? (x - p[x] ? (p[x] = find1(p[x])) : x) : -1;
}
inline void union1(int x, int y) {
  x = find1(x);
  y = find1(y);
  if (x == y) return;
  if (!(~x) || !(~y)) return;
  if (s[y] < s[x])
    p[y] = x, s[x] += s[y], s[y] = 0;
  else
    p[x] = y, s[y] += s[x], s[x] = 0;
}
int main() {
  scanf("%d%d", &n, &k);
  memset(p, 0xff, sizeof(p));
  for (int i = 0; i < n; ++i) scanf("%s", map[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (map[i][j] == '.')
        p[((i)*n + (j) + 1)] = ((i)*n + (j) + 1), s[((i)*n + (j) + 1)] = 1;
      if (j > 0 && map[i][j - 1] == '.' && map[i][j] == '.')
        union1(((i)*n + (j - 1) + 1), ((i)*n + (j) + 1));
      if (i > 0 && map[i - 1][j] == '.' && map[i][j] == '.')
        union1(((i - 1) * n + (j) + 1), ((i)*n + (j) + 1));
    }
  for (int i = 0; i <= n - k; ++i) {
    if (i > 0) {
      for (int x = i - 1; x - i + 1 < k; ++x)
        for (int y = n - k; y < n; ++y)
          if (map[x][y] == '.') ++s[find1(((x)*n + (y) + 1))];
    }
    for (int x = i; x - i < k; ++x)
      for (int y = 0; y < k; ++y)
        if (map[x][y] == '.') --s[find1(((x)*n + (y) + 1))];
    for (int j = 0; j <= n - k; ++j) {
      int t = k * k;
      if (j > 0)
        for (int x = i; x - i < k; ++x) {
          if (map[x][j - 1] == '.') ++s[find1(((x)*n + (j - 1) + 1))];
          if (map[x][j + k - 1] == '.') --s[find1(((x)*n + (j + k - 1) + 1))];
        }
      if (i > 0)
        for (int y = j; y - j < k; ++y)
          if (map[i - 1][y] == '.' && !v[find1(((i - 1) * n + (y) + 1))])
            t += s[find1(((i - 1) * n + (y) + 1))],
                v[find1(((i - 1) * n + (y) + 1))] = 1;
      if (i + k < n)
        for (int y = j; y - j < k; ++y)
          if (map[i + k][y] == '.' && !v[find1(((i + k) * n + (y) + 1))])
            t += s[find1(((i + k) * n + (y) + 1))],
                v[find1(((i + k) * n + (y) + 1))] = 1;
      if (j > 0)
        for (int x = i; x - i < k; ++x)
          if (map[x][j - 1] == '.' && !v[find1(((x)*n + (j - 1) + 1))])
            t += s[find1(((x)*n + (j - 1) + 1))],
                v[find1(((x)*n + (j - 1) + 1))] = 1;
      if (j + k < n)
        for (int x = i; x - i < k; ++x)
          if (map[x][j + k] == '.' && !v[find1(((x)*n + (j + k) + 1))])
            t += s[find1(((x)*n + (j + k) + 1))],
                v[find1(((x)*n + (j + k) + 1))] = 1;
      ans = ((ans) > (t) ? (ans) : (t));
      if (i > 0)
        for (int y = j; y - j < k; ++y)
          if (map[i - 1][y] == '.' && v[find1(((i - 1) * n + (y) + 1))])
            v[find1(((i - 1) * n + (y) + 1))] = 0;
      if (i + k < n)
        for (int y = j; y - j < k; ++y)
          if (map[i + k][y] == '.' && v[find1(((i + k) * n + (y) + 1))])
            v[find1(((i + k) * n + (y) + 1))] = 0;
      if (j > 0)
        for (int x = i; x - i < k; ++x)
          if (map[x][j - 1] == '.' && v[find1(((x)*n + (j - 1) + 1))])
            v[find1(((x)*n + (j - 1) + 1))] = 0;
      if (j + k < n)
        for (int x = i; x - i < k; ++x)
          if (map[x][j + k] == '.' && v[find1(((x)*n + (j + k) + 1))])
            v[find1(((x)*n + (j + k) + 1))] = 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}
