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;
long long n, m, y, z, now, ans, dp[5005], l[5005], r[5005], u[5005], d[5005],
    lh[5005], rh[5005], uh[5005], dh[5005];
char a[5005], c;
void dsu(long long x) {
  if (a[x] == 'U' && !uh[x]) {
    return;
  }
  if (a[x] == 'D' && !dh[x]) {
    return;
  }
  if (a[x] == 'R' && !rh[x]) {
    return;
  }
  if (a[x] == 'L' && !lh[x]) {
    return;
  }
  ans++;
  y = lh[x], z = rh[x];
  rh[y] = z, lh[z] = y;
  y = uh[x], z = dh[x];
  dh[y] = z, uh[z] = y;
  if (a[x] == 'U') {
    dsu(uh[x]);
  } else if (a[x] == 'R') {
    dsu(rh[x]);
  } else if (a[x] == 'L') {
    dsu(lh[x]);
  } else if (a[x] == 'D') {
    dsu(dh[x]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c;
      a[(i - 1) * m + j] = c;
    }
  }
  for (int i = 1; i <= m; i++) {
    now = 0;
    for (int j = 1; j <= n; j++) {
      if (a[(j - 1) * m + i] == '.') {
        continue;
      }
      d[now] = (j - 1) * m + i;
      u[(j - 1) * m + i] = now;
      now = (j - 1) * m + i;
    }
    d[now] = 0;
  }
  for (int i = 1; i <= n; i++) {
    now = 0;
    for (int j = 1; j <= m; j++) {
      if (a[(i - 1) * m + j] == '.') {
        continue;
      }
      r[now] = (i - 1) * m + j;
      l[(i - 1) * m + j] = now;
      now = (i - 1) * m + j;
    }
    r[now] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int q = 1; q <= m; q++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= m; k++) {
          lh[(j - 1) * m + k] = l[(j - 1) * m + k];
          rh[(j - 1) * m + k] = r[(j - 1) * m + k];
          uh[(j - 1) * m + k] = u[(j - 1) * m + k];
          dh[(j - 1) * m + k] = d[(j - 1) * m + k];
        }
      }
      ans = 1;
      if (a[(i - 1) * m + q] != '.') {
        dsu((i - 1) * m + q);
        dp[ans]++;
      }
    }
  }
  for (int i = 5000; i >= 1; i--) {
    if (dp[i]) {
      cout << i << " " << dp[i] << '\n';
      return 0;
    }
  }
}
