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;
const int N = 5036;
bool vis[N][N];
char s[N][N];
short pr[2][N][N];
short ne[2][N][N];
int n, m;
void ER(int first, int second, char c) {
  if (vis[first][second]) return;
  vis[first][second] = 1;
  {
    int v1 = pr[0][first][second];
    int v2 = ne[0][first][second];
    if (v2 != -1) pr[0][first][v2] = v1;
    if (v1 != -1) ne[0][first][v1] = v2;
  }
  {
    int u1 = pr[1][first][second];
    int u2 = ne[1][first][second];
    if (u2 != -1) pr[1][u2][second] = u1;
    if (u1 != -1) ne[1][u1][second] = u2;
  }
}
void LK(int first, int second, int a, int b) {
  if (first == a) {
    ne[0][first][second] = b;
    pr[0][first][b] = second;
  } else {
    ne[1][first][second] = a;
    pr[1][a][second] = first;
  }
}
void init() {
  for (int k = (0); k < (int)(2); k++)
    for (int i = (0); i < (int)(n); i++)
      for (int j = (0); j < (int)(m); j++) {
        pr[k][i][j] = -1;
        ne[k][i][j] = -1;
        vis[i][j] = 0;
      }
  for (int first = (0); first < (int)(n); first++) {
    int second = 0;
    while (second < m && s[first][second] == '.') ++second;
    for (; second < m;) {
      int v = second + 1;
      while (v < m && s[first][v] == '.') ++v;
      if (v >= m) break;
      LK(first, second, first, v);
      second = v;
    }
  }
  for (int second = (0); second < (int)(m); second++) {
    int first = 0;
    while (first < n && s[first][second] == '.') ++first;
    for (; first < n;) {
      int u = first + 1;
      while (u < n && s[u][second] == '.') ++u;
      if (u >= n) break;
      LK(first, second, u, second);
      first = u;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (int)(n); i++) scanf("%s", s[i]);
  int best = 0;
  int hv = n * m;
  for (int i = (0); i < (int)(n); i++)
    for (int j = (0); j < (int)(m); j++) {
      if (s[i][j] != '.') {
        init();
        int cur = 0;
        int first = i, second = j;
        while (first != -1 && second != -1) {
          int a, b;
          if (s[first][second] == 'R') {
            a = first;
            b = ne[0][first][second];
          } else if (s[first][second] == 'L') {
            a = first;
            b = pr[0][first][second];
          } else if (s[first][second] == 'D') {
            a = ne[1][first][second];
            b = second;
          } else if (s[first][second] == 'U') {
            a = pr[1][first][second];
            b = second;
          }
          ER(first, second, s[first][second]);
          first = a;
          second = b;
          ++cur;
        }
        if (cur == best) {
          hv++;
        } else if (cur > best) {
          best = cur;
          hv = 1;
        }
      }
    }
  printf("%d %d\n", best, hv);
  return 0;
}
