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 MaxN = 5005;
vector<string> g;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
vector<int> Set[4][MaxN];
int Get(char c) {
  if (c == 'R') return 0;
  if (c == 'D') return 1;
  if (c == 'L') return 2;
  return 3;
}
int n, m;
bool check(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= m) return 0;
  return 1;
}
char s[MaxN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    string t = s;
    g.push_back(t);
    for (int j = 0; j < m; j++)
      for (int k = 0; k < 4; k++) Set[k][i].push_back(0);
  }
  int ret = 0, a = 0;
  for (int x = 0; x < n; x++)
    for (int y = 0; y < m; y++)
      if (g[x][y] != '.') {
        for (int i = 0; i < n; i++) {
          int p = -1;
          for (int j = 0; j < m; j++)
            if (g[i][j] != '.') {
              Set[2][i][j] = p;
              p = j;
            }
        }
        for (int i = 0; i < n; i++) {
          int p = m;
          for (int j = m - 1; j >= 0; j--)
            if (g[i][j] != '.') {
              Set[0][i][j] = p;
              p = j;
            }
        }
        for (int i = 0; i < m; i++) {
          int p = -1;
          for (int j = 0; j < n; j++)
            if (g[j][i] != '.') {
              Set[3][j][i] = p;
              p = j;
            }
        }
        for (int i = 0; i < m; i++) {
          int p = n;
          for (int j = n - 1; j >= 0; j--)
            if (g[j][i] != '.') {
              Set[1][j][i] = p;
              p = j;
            }
        }
        int nx = x, ny = y, ct = 1;
        while (1) {
          int d = Get(g[nx][ny]);
          int xx, yy;
          if (d == 0 || d == 2)
            xx = nx, yy = Set[d][nx][ny];
          else
            yy = ny, xx = Set[d][nx][ny];
          if (!check(xx, yy)) break;
          int tx[4], ty[4];
          for (d = 0; d < 4; d++) {
            if (d == 0 || d == 2)
              tx[d] = nx, ty[d] = Set[d][nx][ny];
            else
              ty[d] = ny, tx[d] = Set[d][nx][ny];
          }
          for (d = 0; d < 4; d++)
            if (check(tx[d], ty[d])) {
              Set[(d + 2) % 4][tx[d]][ty[d]] =
                  ((d == 0 || d == 2) ? ty[(d + 2) % 4] : tx[(d + 2) % 4]);
            }
          ct++;
          nx = xx, ny = yy;
        }
        if (ret < ct) {
          ret = ct;
          a = 1;
        } else if (ret == ct)
          a++;
      }
  printf("%d %d\n", ret, a);
  return 0;
}
