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>
const int maxi = 2000000000;
const int maxq = 1000000000;
const double eps = 1e-10;
using namespace std;
short n, m, ni[5009][5009], nj[5009][5009], pi[5009][5009], pj[5009][5009];
int sum, xx, yy;
char a[5009][5009];
int main() {
  cin >> n >> m;
  scanf("\n");
  int _max = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%c", &a[i][j]);
    scanf("\n");
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] != '.') {
        for (int i = 1; i <= n; i++) {
          int nomj = 0;
          for (int j = 1; j <= m; j++)
            if (a[i][j] != '.') {
              pj[i][j] = nomj;
              nj[i][nomj] = j;
              nomj = j;
            }
          nj[i][nomj] = 0;
        }
        for (int j = 1; j <= m; j++) {
          int nomi = 0;
          for (int i = 1; i <= n; i++)
            if (a[i][j] != '.') {
              pi[i][j] = nomi;
              ni[nomi][j] = i;
              nomi = i;
            }
          ni[nomi][j] = 0;
        }
        int x = i;
        int y = j;
        sum = 0;
        while (a[x][y] == 'L' || a[x][y] == 'R' || a[x][y] == 'U' ||
               a[x][y] == 'D') {
          if (a[x][y] == 'L') {
            yy = pj[x][y];
            pj[x][nj[x][y]] = yy;
            nj[x][pj[x][y]] = nj[x][y];
            pi[ni[x][y]][y] = pi[x][y];
            ni[pi[x][y]][y] = ni[x][y];
            y = yy;
            if (y == maxi || y == 0) break;
            sum++;
            continue;
          }
          if (a[x][y] == 'R') {
            yy = nj[x][y];
            nj[x][pj[x][y]] = yy;
            pj[x][nj[x][y]] = pj[x][y];
            pi[ni[x][y]][y] = pi[x][y];
            ni[pi[x][y]][y] = ni[x][y];
            y = yy;
            if (y == maxi || y == 0) break;
            sum++;
            continue;
          }
          if (a[x][y] == 'U') {
            xx = pi[x][y];
            pi[ni[x][y]][y] = xx;
            ni[pi[x][y]][y] = ni[x][y];
            pj[x][nj[x][y]] = pj[x][y];
            nj[x][pj[x][y]] = nj[x][y];
            x = xx;
            if (xx == maxi || xx == 0) break;
            sum++;
            continue;
          }
          if (a[x][y] == 'D') {
            xx = ni[x][y];
            ni[pi[x][y]][y] = xx;
            pi[ni[x][y]][y] = pi[x][y];
            pj[x][nj[x][y]] = pj[x][y];
            nj[x][pj[x][y]] = nj[x][y];
            x = xx;
            if (x == maxi || x == 0) break;
            sum++;
            continue;
          }
        }
        if (sum > _max) {
          _max = sum;
          ans = 0;
        }
        if (sum == _max) ans++;
      }
  cout << _max + 1 << ' ' << ans << endl;
}
