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 mod = 1000000007;
long long n, k, t, m, q, flag = 0;
long long power(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  t = 1;
  while (t--) {
    cin >> n >> m;
    char a[n][m];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> a[i][j];
    long long rown[n][m], rowp[n][m], coln[n][m], colp[n][m];
    int ans = 0, maxcount = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (a[i][j] == '.') continue;
        for (int i1 = 0; i1 < n; i1++)
          for (int j1 = 0; j1 < m; j1++)
            rown[i1][j1] = i1 + 1, rowp[i1][j1] = i1 - 1, coln[i1][j1] = j1 + 1,
            colp[i1][j1] = j1 - 1;
        for (int i1 = 0; i1 < n; i1++)
          for (int j1 = 0; j1 < m; j1++)
            if (a[i1][j1] == '.') {
              if (rowp[i1][j1] != -1) rown[rowp[i1][j1]][j1] = rown[i1][j1];
              if (rown[i1][j1] != n) rowp[rown[i1][j1]][j1] = rowp[i1][j1];
              if (colp[i1][j1] != -1) coln[i1][colp[i1][j1]] = coln[i1][j1];
              if (coln[i1][j1] != m) colp[i1][coln[i1][j1]] = colp[i1][j1];
            }
        long long count = 0;
        int i1 = i, j1 = j;
        count++;
        while (1) {
          if (rowp[i1][j1] != -1) rown[rowp[i1][j1]][j1] = rown[i1][j1];
          if (rown[i1][j1] != n) rowp[rown[i1][j1]][j1] = rowp[i1][j1];
          if (colp[i1][j1] != -1) coln[i1][colp[i1][j1]] = coln[i1][j1];
          if (coln[i1][j1] != m) colp[i1][coln[i1][j1]] = colp[i1][j1];
          if (a[i1][j1] == 'D') {
            if (rown[i1][j1] == n)
              break;
            else {
              count++;
              i1 = rown[i1][j1];
            }
          } else if (a[i1][j1] == 'U') {
            if (rowp[i1][j1] == -1)
              break;
            else {
              count++;
              i1 = rowp[i1][j1];
            }
          } else if (a[i1][j1] == 'R') {
            if (coln[i1][j1] == m)
              break;
            else {
              count++;
              j1 = coln[i1][j1];
            }
          } else if (a[i1][j1] == 'L') {
            if (colp[i1][j1] == -1)
              break;
            else {
              count++;
              j1 = colp[i1][j1];
            }
          }
        }
        if (count == ans)
          maxcount++;
        else if (count > ans)
          ans = count, maxcount = 1;
      }
    cout << ans << " " << maxcount;
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
