// Mahmud Isali
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long INF = 4e18, MOD = 998244353, N = 1e5 + 5;
void solve() {
int n,m;
cin >> n >> m;
int cnt1 = 0, cnt2 = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
char c;
cin >> c;
if(c == 'F') cnt1 = 1;
else if(c == 'R') cnt2 = 1;
}
}
cout << cnt1 + cnt2 << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "\n-----Case-----" << i << "\n";
solve();
}
}