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;
int up[5002], dw[5002], pl[5002], pr[5002];
int tup[5002], tdw[5002], tpl[5002], tpr[5002];
char mp[5002][5002];
int n, m;
void cpy() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      tup[i * m + j] = up[i * m + j];
      tdw[i * m + j] = dw[i * m + j];
      tpl[i * m + j] = pl[i * m + j];
      tpr[i * m + j] = pr[i * m + j];
    }
  }
}
void del(int p) {
  tup[tdw[p]] = tup[p];
  tpl[tpr[p]] = tpl[p];
  tpr[tpl[p]] = tpr[p];
  tdw[tup[p]] = tdw[p];
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mp[i][j];
    }
  }
  memset(up, -1, sizeof(up));
  memset(dw, -1, sizeof(dw));
  memset(pr, -1, sizeof(pr));
  memset(pl, -1, sizeof(pl));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.') continue;
      for (int k = i - 1; k >= 0; k--)
        if (mp[k][j] != '.') {
          up[i * m + j] = k * m + j;
          break;
        }
      for (int k = j - 1; k >= 0; k--)
        if (mp[i][k] != '.') {
          pl[i * m + j] = i * m + k;
          break;
        }
      for (int k = i + 1; k < n; k++)
        if (mp[k][j] != '.') {
          dw[i * m + j] = k * m + j;
          break;
        }
      for (int k = j + 1; k < m; k++)
        if (mp[i][k] != '.') {
          pr[i * m + j] = i * m + k;
          break;
        }
    }
  }
  int minstep = 1, num = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.') continue;
      cpy();
      int x = i, y = j;
      int step = 1;
      while (1) {
        int pos = x * m + y;
        if (mp[x][y] == 'U' && tup[pos] >= 0) {
          x = tup[pos] / m;
          y = tup[pos] % m;
        } else if (mp[x][y] == 'D' && tdw[pos] >= 0) {
          x = tdw[pos] / m;
          y = tdw[pos] % m;
        } else if (mp[x][y] == 'R' && tpr[pos] >= 0) {
          x = tpr[pos] / m;
          y = tpr[pos] % m;
        } else if (mp[x][y] == 'L' && tpl[pos] >= 0) {
          x = tpl[pos] / m;
          y = tpl[pos] % m;
        } else
          break;
        del(pos);
        step++;
      }
      if (minstep == step)
        num++;
      else if (minstep < step) {
        minstep = step;
        num = 1;
      }
    }
  }
  cout << minstep << " " << num << endl;
  return 0;
}
