#include<stdio.h> int R, C; char buf[10000][501]; int visit[10000][500]; int pipe = 0; intDFS(int y, int x) { if (y < 0 || x < 0 || y >= R || x >= C) return0; if (buf[y][x] == 'x') return0; if (visit[y][x]) return0; if (x == C - 1) { buf[y][x] = 'x'; ++pipe; return1; } visit[y][x] = 1; if (DFS(y - 1, x + 1)) { buf[y][x] = 'x'; return1; } if (DFS(y, x + 1)) { buf[y][x] = 'x'; return1; } if (DFS(y + 1, x + 1)) { buf[y][x] = 'x'; return1; } return0; }
intmain(void) { scanf("%d %d", &R, &C); for (int i = 0; i < R; ++i) scanf("%s", buf[i]); for (int i = 0; i < R; ++i) { DFS(i, 0); } printf("%d", pipe); }