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 n, m;
int f[4][15111 + 1];
char Board[15111 + 1];
int getx[15111];
int gety[15111];
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
int trans(int x, int y) { return x * (m + 2) + y; }
int outBoard(int x, int y) { return (x < 1 || y < 1 || x > n || y > m); }
int getdir(int x, int y) {
  if (Board[trans(x, y)] == 'L') return 0;
  if (Board[trans(x, y)] == 'R') return 1;
  if (Board[trans(x, y)] == 'D') return 2;
  if (Board[trans(x, y)] == 'U') return 3;
  return -1;
}
int getf(int dir, int w) {
  return f[dir][w] == w ? w : f[dir][w] = getf(dir, f[dir][w]);
}
void delit(int x, int y) {
  int id = trans(x, y);
  for (int i = 0; i < 4; i++) f[i][id] = trans(x + dx[i], y + dy[i]);
}
int solve(int x, int y) {
  for (int i = 0; i < 15111; i++)
    for (int j = 0; j < 4; j++) f[j][i] = i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (Board[trans(i, j)] == '.') delit(i, j);
  delit(x, y);
  int ret = 0;
  while (1) {
    if (outBoard(x, y)) break;
    ret++;
    int dir = getdir(x, y);
    int cur = trans(x + dx[dir], y + dy[dir]);
    cur = getf(dir, cur);
    x = getx[cur];
    y = gety[cur];
    delit(x, y);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    for (int i = 0; i <= n + 1; i++)
      for (int j = 0; j <= m + 1; j++) {
        getx[trans(i, j)] = i;
        gety[trans(i, j)] = j;
      }
    for (int i = 1; i <= n; i++) {
      string s;
      cin >> s;
      s = " " + s;
      for (int j = 1; j <= m; j++) Board[trans(i, j)] = s[j];
    }
    int MAXANS = 0, CNT = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (Board[trans(i, j)] != '.') {
          int t = solve(i, j);
          if (t > MAXANS) MAXANS = t, CNT = 0;
          if (t == MAXANS) {
            CNT++;
          }
        }
    cout << MAXANS << " " << CNT << endl;
  }
  return 0;
}
