#include <bits/stdc++.h>
using namespace std;
int main() {
  char item[21][21];
  int i, j, s = 0;
  int H, W;
  cin >> H >> W;
  for (int i = 1; i <= H; i++)
    for (int j = 1; j <= W; j++) cin >> item[i][j];
  i = H, j = 1;
  while (!(i == 1 && j == W)) {
    item[i][j] = '*';
    if (item[i][j + 1] != '.') {
      if (i - 1 >= 1 && item[i - 1][j] == '.')
        i--;
      else {
        i++;
      }
    } else {
      if (j + 1 <= W)
        j++;
      else {
        j--;
      }
    }
    s++;
  }
  cout << s;
}
