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;
char matr[5000][5000];
bool used[5000][5000];
short lft[5000][5000], rght[5000][5000], up[5000][5000], down[5000][5000];
int main() {
  int n, m;
  cin >> n >> m;
  int** lft1 = new int*[n];
  for (int i = 0; i < n; i++) lft1[i] = new int[m];
  int** rght1 = new int*[n];
  for (int i = 0; i < n; i++) rght1[i] = new int[m];
  int** up1 = new int*[n];
  for (int i = 0; i < n; i++) up1[i] = new int[m];
  int** down1 = new int*[n];
  for (int i = 0; i < n; i++) down1[i] = new int[m];
  int** res = new int*[n];
  for (int i = 0; i < n; i++) res[i] = new int[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      lft[i][j] = -1;
      rght[i][j] = -1;
      up[i][j] = -1;
      down[i][j] = -1;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> matr[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (matr[i][j] != '.') {
        for (int k = 1; i + k < n; k++) {
          if (matr[i + k][j] != '.') {
            down[i][j] = i + k;
            break;
          }
        }
        for (int k = 1; i - k >= 0; k++) {
          if (matr[i - k][j] != '.') {
            up[i][j] = i - k;
            break;
          }
        }
        for (int k = 1; j + k < m; k++) {
          if (matr[i][j + k] != '.') {
            rght[i][j] = j + k;
            break;
          }
        }
        for (int k = 1; j - k >= 0; k++) {
          if (matr[i][j - k] != '.') {
            lft[i][j] = j - k;
            break;
          }
        }
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (matr[i][j] == '.') continue;
      for (int k = 0; k < n; k++)
        for (int l = 0; l < m; l++) {
          lft1[k][l] = lft[k][l];
          rght1[k][l] = rght[k][l];
          up1[k][l] = up[k][l];
          down1[k][l] = down[k][l];
        }
      int cnt = 0, i1 = i, j1 = j;
      while (matr[i1][j1] != '.') {
        if (up1[i1][j1] != -1) down1[up1[i1][j1]][j1] = down1[i1][j1];
        if (down1[i1][j1] != -1) up1[down1[i1][j1]][j1] = up1[i1][j1];
        if (lft1[i1][j1] != -1) rght1[i1][lft1[i1][j1]] = rght1[i1][j1];
        if (rght1[i1][j1] != -1) lft1[i1][rght1[i1][j1]] = lft1[i1][j1];
        if (matr[i1][j1] == 'U') {
          i1 = up1[i1][j1];
          cnt++;
          if (i1 == -1) goto nxt;
        } else if (matr[i1][j1] == 'D') {
          i1 = down1[i1][j1];
          cnt++;
          if (i1 == -1) goto nxt;
        } else if (matr[i1][j1] == 'L') {
          j1 = lft1[i1][j1];
          cnt++;
          if (j1 == -1) goto nxt;
        } else if (matr[i1][j1] == 'R') {
          j1 = rght1[i1][j1];
          cnt++;
          if (j1 == -1) goto nxt;
        }
      }
    nxt:;
      res[i][j] = cnt;
    }
  int maxi = 0, cnt1 = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) maxi = max(maxi, res[i][j]);
  cout << maxi << " ";
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (res[i][j] == maxi) cnt1++;
  cout << cnt1 << endl;
  return 0;
}
