#include <bits/stdc++.h>
using namespace std;
int n, m;
char g[100][100];
int main() {
  scanf("%d%d", &n, &m);
  int an = m, mx = 0;
  for (int i = 0; i < n; ++i) {
    int c = 0, ct = 0, tt = 0;
    for (int j = 0; j < m; ++j) {
      cin >> g[i][j];
      if (g[i][j] == '.')
        ct += (c != 0), c = 0;
      else
        ++c, ++tt;
    }
    ct += (c != 0);
    if (tt && tt > mx) mx = tt, an = ct;
    if (tt && tt == mx) an = min(an, ct);
  }
  printf("%d\n", an);
}
