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 = 5005;
vector<vector<vector<int>>> nxt(4);
int n, m;
char grid[5005][5005];
int cnt = 0;
vector<pair<int, int>> rollback;
vector<vector<vector<int>>> base;
int solve(int sx, int sy) {
  int ret = 0;
  while (sx >= 0 && sx < n && sy >= 0 && sy < m) {
    int L = nxt[0][sx][sy];
    int R = nxt[1][sx][sy];
    if (L >= 0) nxt[1][sx][L] = R, rollback.push_back(pair<int, int>(sx, L));
    if (R < m) nxt[0][sx][R] = L, rollback.push_back(pair<int, int>(sx, R));
    int U = nxt[2][sx][sy];
    int D = nxt[3][sx][sy];
    if (D < n) nxt[2][D][sy] = U, rollback.push_back(pair<int, int>(D, sy));
    if (U >= 0) nxt[3][U][sy] = D, rollback.push_back(pair<int, int>(U, sy));
    ret++;
    if (grid[sx][sy] == 'D') {
      sx = nxt[3][sx][sy];
    } else if (grid[sx][sy] == 'R') {
      sy = nxt[1][sx][sy];
    } else if (grid[sx][sy] == 'U') {
      sx = nxt[2][sx][sy];
    } else {
      sy = nxt[0][sx][sy];
    }
  }
  for (int i = 0; i < rollback.size(); i++) {
    int x, y;
    tie(x, y) = rollback[i];
    nxt[0][x][y] = base[0][x][y];
    nxt[1][x][y] = base[1][x][y];
    nxt[2][x][y] = base[2][x][y];
    nxt[3][x][y] = base[3][x][y];
  }
  rollback.clear();
  return ret;
}
int main() {
  srand(time(0));
  scanf("%d%d", &n, &m);
  nxt[0] = vector<vector<int>>(n, vector<int>(m));
  nxt[1] = vector<vector<int>>(n, vector<int>(m));
  nxt[2] = vector<vector<int>>(n, vector<int>(m));
  nxt[3] = vector<vector<int>>(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf(" %c", &grid[i][j]);
  for (int i = 0; i < n; i++) {
    int b4 = -1;
    for (int j = 0; j < m; j++) {
      nxt[0][i][j] = b4;
      if (grid[i][j] != '.') b4 = j;
    }
    b4 = m;
    for (int j = m - 1; j >= 0; --j) {
      nxt[1][i][j] = b4;
      if (grid[i][j] != '.') b4 = j;
    }
  }
  for (int j = 0; j < m; j++) {
    int b4 = -1;
    for (int i = 0; i < n; i++) {
      nxt[2][i][j] = b4;
      if (grid[i][j] != '.') b4 = i;
    }
    b4 = n;
    for (int i = n - 1; i >= 0; --i) {
      nxt[3][i][j] = b4;
      if (grid[i][j] != '.') b4 = i;
    }
  }
  int ans = 0, cnt = 1;
  base = nxt;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (grid[i][j] != '.') {
        int x = solve(i, j);
        if (x > ans) cnt = 0, ans = x;
        if (x == ans) cnt++;
      }
    }
  cout << ans << ' ' << cnt << '\n';
  return 0;
}
