#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, i, j, count = 0, c;
  cin >> r >> c;
  char a[r][c];
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) cin >> a[i][j];
  }
  for (j = 0; j < c - 1; j++) {
    if (a[r - 1][j] != a[r - 1][j + 1]) count++;
  }
  if (count % 2 != 0)
    cout << (count + 1) / 2;
  else {
    if (a[r - 1][0] == '.')
      cout << count / 2;
    else
      cout << (count / 2) + 1;
  }
}
