N,M = map(int,input().split()) A = [list(input()) for x in range(N)] ans = 0 for x in range(N): for y in range(M): if A[x][y] != "R": ans += 1 print(ans)