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>
#pragma GCC optimize("O3")
using namespace std;
const int N = 5e3 + 5;
int n, m;
char a[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int ans = 0, t = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.') continue;
      int lstR[m + 5], lstC[n + 5];
      int nxt[n + 5][m + 5][4];
      memset(lstR, -1, sizeof lstR);
      memset(lstC, -1, sizeof lstC);
      memset(nxt, -1, sizeof nxt);
      for (int p1 = 0; p1 < n; p1++)
        for (int p2 = 0; p2 < m; p2++) {
          if (a[p1][p2] == '.') continue;
          if (~lstR[p2]) {
            nxt[p1][p2][0] = lstR[p2];
            nxt[lstR[p2]][p2][1] = p1;
          }
          if (~lstC[p1]) {
            nxt[p1][p2][2] = lstC[p1];
            nxt[p1][lstC[p1]][3] = p2;
          }
          lstR[p2] = p1, lstC[p1] = p2;
        }
      int curi = i, curj = j, cnt = 0;
      while (1) {
        cnt++;
        if (~nxt[curi][curj][1])
          nxt[nxt[curi][curj][1]][curj][0] = nxt[curi][curj][0];
        if (~nxt[curi][curj][0])
          nxt[nxt[curi][curj][0]][curj][1] = nxt[curi][curj][1];
        if (~nxt[curi][curj][2])
          nxt[curi][nxt[curi][curj][2]][3] = nxt[curi][curj][3];
        if (~nxt[curi][curj][3])
          nxt[curi][nxt[curi][curj][3]][2] = nxt[curi][curj][2];
        if (a[curi][curj] == 'U') {
          if (nxt[curi][curj][0] == -1) break;
          curi = nxt[curi][curj][0];
        } else if (a[curi][curj] == 'D') {
          if (nxt[curi][curj][1] == -1) break;
          curi = nxt[curi][curj][1];
        } else if (a[curi][curj] == 'L') {
          if (nxt[curi][curj][2] == -1) break;
          curj = nxt[curi][curj][2];
        } else {
          if (nxt[curi][curj][3] == -1) break;
          curj = nxt[curi][curj][3];
        }
      }
      if (ans < cnt)
        ans = cnt, t = 1;
      else if (ans == cnt)
        t++;
    }
  cout << ans << " " << t;
  return 0;
}
