10 10
.L.....R..
.........U
..D....D..
.R......L.
....L.....
.........D
......U...
D....R....
...U......
........L.
 5 5
DD..D
.....
LU...
U...U
.UL.U
 1 1
U
 5 5
UD..L
RRD..
..RDD
UUL..
DDLRR
 19 23
U..U..R........L...D...
.D.....UL.U.U........DR
..D.U..D....L......R...
D.......RL.L....D.....R
U..D.....U...U.L..D...U
...........L...........
U....U....D.U......LRR.
......RL...U...L.......
DLU..U......UU.U.U.D...
...........D....U......
U...DL......LL.....R...
...U..DD..........LD...
.R.........D.....UU...U
....D......R..........D
.L..........R.....L....
.R........L.LL....R....
..R...D........R....D..
.LR.R..LDU.DDRL......U.
...LL.....D.....DD.....
 11 29
URRUUDDLURLRDDLLRLDUDR.UDLLD.
LRRUDLUDLDULUDL.DURDRR.RRLLRR
D.DUDDURLRDDULDUDDUDDURRDLD.L
.RULURURRDLRRRLUUUU.RDLDLRRRL
.RLDDU.UUULUURURRLLUU.RLDRDUD
LRL.URRRDDURUURUDRRDLDDULRDRL
RLULDU.LRDUDRLDLRDDDDRUUDRDLL
DLUDURRDDUDLLDLLUURLDRUURRLUL
L.RRURRDDRRURRRDDUDRRDULR.LUR
LDLRULURRUULRDUUULLU.LLU.LLLL
DUURDULDDUDLRUUDRUULURLD.RL.U
 2 2
RD
UL
 1 10
LLLLLRRRRR
 3 3
...
...
..R
 17 13
...LD.UR.RUU.
LDLULDUDRRDRL
DD.RRLRUR.UD.
RU...D...LD..
.UR.R...URUUD
.RURD.RLR.D.R
.UUU.RU...UR.
UUUU.R.......
RL.LRU.UD.DUD
LD.DRURRLRDRL
.DR..UULUDDR.
LRLURRUUDDLUR
.LRDDLLR.L.DU
DRUDLLD.LRRU.
..DL.UDL.DUL.
U.DL..D..U.RD
RR.R...RL.L..

2 2
 4 1
 1 1
 8 3
 9 1
 94 1
 4 4
 5 2
 1 1
 24 2

#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int M = 1000100;
const int MAXN = 50050;
const int MAXM = 50050;
char mp[5050];
bool vis[5050];
int ac[5050];
int n, m;
vector<int> ans;
void solve(int x, int cnt) {
  if (mp[x] == 'U') {
    if (x <= m) {
      ans.push_back(cnt);
      return;
    }
    int t = x - m;
    while ((mp[t] == '.' || vis[t]) && t >= 1) {
      t -= m;
    }
    if (t < 1) {
      ans.push_back(cnt);
      return;
    }
    if (vis[t]) return;
    vis[t] = 1;
    solve(t, cnt + 1);
  } else if (mp[x] == 'D') {
    if (x >= (n - 1) * m) {
      ans.push_back(cnt);
      return;
    }
    int t = x + m;
    while ((mp[t] == '.' || vis[t]) && t <= n * m) {
      t += m;
    }
    if (t > n * m) {
      ans.push_back(cnt);
      return;
    }
    if (vis[t]) return;
    vis[t] = 1;
    solve(t, cnt + 1);
  } else if (mp[x] == 'R') {
    if (x % m == 0) {
      ans.push_back(cnt);
      return;
    }
    int t = x + 1;
    int res = t % m;
    if (!res) res = m;
    while ((mp[t] == '.' || vis[t]) && res <= m) {
      t++;
      res++;
    }
    if (res > m) {
      ans.push_back(cnt);
      return;
    }
    if (vis[t]) return;
    vis[t] = 1;
    solve(t, cnt + 1);
  } else {
    if (x % m == 1) {
      ans.push_back(cnt);
      return;
    }
    int t = x - 1;
    int res = t % m;
    while ((mp[t] == '.' || vis[t]) && res >= 1) {
      t--;
      res--;
    }
    if (res < 1) {
      ans.push_back(cnt);
      return;
    }
    if (vis[t]) return;
    vis[t] = 1;
    solve(t, cnt + 1);
  }
}
int main() {
  cin >> n >> m;
  cin.ignore();
  for (int i = 1; i <= n * m; ++i) {
    scanf("%c", &mp[i]);
    if (i % m == 0 && i != n * m) cin.ignore();
  }
  for (int i = 1; i <= n * m; ++i) {
    if (mp[i] != '.') {
      memset(vis, 0, sizeof(vis[0]) * n * m);
      vis[i] = 1;
      solve(i, 1);
    }
  }
  sort(ans.begin(), ans.end(), [](int a, int b) { return a > b; });
  cout << ans[0] << " ";
  int c = 1;
  for (int i = 1; i < ans.size(); ++i) {
    if (ans[i] != ans[i - 1]) break;
    c++;
  }
  cout << c << endl;
  return 0;
}
