#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:67108864")
using namespace std;
void precalc() {}
int comp_sum[500000];
char mp[600][600];
int n, k;
int comp[600][600];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int cur_comp = 1;
int sum_block[600][600];
int pref_sum_row[600][600];
bool dfs(int x, int y) {
  if (comp[x][y] != 0 || mp[x][y] != '.') {
    return false;
  }
  comp[x][y] = cur_comp;
  for (int dir = 0; dir < 4; ++dir) {
    dfs(x + dx[dir], y + dy[dir]);
  }
  return true;
}
int used[250001];
int cur_sum = 0;
void init_used(int i) {
  if (i > 0) {
    for (int j = 0; j < k; ++j) {
      ++used[comp[i - 1][j]];
      if (used[comp[i - 1][j]] == 1) {
        cur_sum += comp_sum[comp[i - 1][j]];
      }
    }
  }
  for (int _i = i; _i < i + k; ++_i) {
    for (int _j = 0; _j <= k; ++_j) {
      ++used[comp[_i][_j]];
      if (used[comp[_i][_j]] == 1) {
        cur_sum += comp_sum[comp[_i][_j]];
      }
    }
  }
  if (i < n - k) {
    for (int j = 0; j < k; ++j) {
      ++used[comp[i + k][j]];
      if (used[comp[i + k][j]] == 1) {
        cur_sum += comp_sum[comp[i + k][j]];
      }
    }
  }
}
void erase(int i, int j) {
  if (i > 0) {
    --used[comp[i - 1][j + 1]];
    if (used[comp[i - 1][j + 1]] == 0) {
      cur_sum -= comp_sum[comp[i - 1][j + 1]];
    }
  }
  for (int _i = i; _i < i + k; ++_i) {
    --used[comp[_i][j]];
    if (used[comp[_i][j]] == 0) {
      cur_sum -= comp_sum[comp[_i][j]];
    }
  }
  if (i < n - k) {
    --used[comp[i + k][j + 1]];
    if (used[comp[i + k][j + 1]] == 0) {
      cur_sum -= comp_sum[comp[i + k][j + 1]];
    }
  }
}
void init_sum_block() {
  for (int i = 0; i <= n - k; ++i) {
    for (int j = 0; j <= n - k; ++j) {
      for (int p = i; p < i + k; ++p) {
        sum_block[i][j] += pref_sum_row[p][j + k - 1];
        if (j > 0) {
          sum_block[i][j] -= pref_sum_row[p][j - 1];
        }
      }
    }
  }
}
int solve() {
  scanf("%d%d\n", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s\n", &mp[i]);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      pref_sum_row[i][j] = (mp[i][j] == '.' ? 0 : 1);
      if (j > 0) {
        pref_sum_row[i][j] += pref_sum_row[i][j - 1];
      }
      if (dfs(i, j)) {
        ++cur_comp;
      }
      if (comp[i][j] != 0) {
        ++comp_sum[comp[i][j]];
      }
    }
  }
  init_sum_block();
  int ans = k * k;
  for (int i = 0; i <= n - k; ++i) {
    memset(used, 0, sizeof used);
    cur_sum = 0;
    for (int j = 0; j <= n - k; ++j) {
      if (j == 0) {
        init_used(i);
      } else {
        erase(i, j - 2);
        if (i > 0) {
          ++used[comp[i - 1][j + k - 1]];
          if (used[comp[i - 1][j + k - 1]] == 1) {
            cur_sum += comp_sum[comp[i - 1][j + k - 1]];
          }
        }
        if (i < n - k) {
          ++used[comp[i + k][j + k - 1]];
          if (used[comp[i + k][j + k - 1]] == 1) {
            cur_sum += comp_sum[comp[i + k][j + k - 1]];
          }
        }
        if (j < n - k) {
          for (int _i = i; _i < i + k; ++_i) {
            ++used[comp[_i][j + k]];
            if (used[comp[_i][j + k]] == 1) {
              cur_sum += comp_sum[comp[_i][j + k]];
            }
          }
        }
      }
      ans = max(ans, cur_sum + sum_block[i][j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
int main() {
  precalc();
  int t;
  t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
  return 0;
}
