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 long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}
const int N = 5005;
int usti[N];
int asti[N];
int onni[N];
int soli[N];
int USTI[N];
int ASTI[N];
int ONNI[N];
int SOLI[N];
char letter[N];
int num[N][N];
char a[N][N];
int main() {
  int K = 0;
  int n = readInt(), m = readInt();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] != '.') {
        K++;
        num[i][j] = K;
        letter[K] = a[i][j];
      }
    }
  }
  int tmp;
  for (int i = 1; i <= n; i++) {
    tmp = -1;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '.') {
        soli[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
    tmp = -1;
    for (int j = m; j >= 1; j--) {
      if (a[i][j] != '.') {
        onni[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    tmp = -1;
    for (int i = 1; i <= n; i++) {
      if (a[i][j] != '.') {
        usti[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
    tmp = -1;
    for (int i = n; i >= 1; i--) {
      if (a[i][j] != '.') {
        asti[num[i][j]] = tmp, tmp = num[i][j];
      }
    }
  }
  int mx = 0;
  int res = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      SOLI[j] = soli[j], ONNI[j] = onni[j], USTI[j] = usti[j],
      ASTI[j] = asti[j];
    }
    int cnt = 0;
    for (int z = i, j; z != -1; z = j) {
      if (letter[z] == 'L') j = SOLI[z];
      if (letter[z] == 'R') j = ONNI[z];
      if (letter[z] == 'U') j = USTI[z];
      if (letter[z] == 'D') j = ASTI[z];
      if (ONNI[z] != -1) SOLI[ONNI[z]] = SOLI[z];
      if (SOLI[z] != -1) ONNI[SOLI[z]] = ONNI[z];
      if (USTI[z] != -1) ASTI[USTI[z]] = ASTI[z];
      if (ASTI[z] != -1) USTI[ASTI[z]] = USTI[z];
      cnt++;
    }
    if (cnt > mx) mx = cnt, res = 0;
    if (cnt == mx) res++;
  }
  cout << mx << ' ' << res;
  return 0;
}
