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 **r;
int **c;
int **R;
int **C;
int n, m;
char **grid;
bool vis[5001][5001];
void ini() {
  int i, j, k;
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++) R[i][j] = 0;
  for (j = 0; j <= m; j++)
    for (i = 0; i <= n; i++) C[j][i] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++)
      if (grid[i][j] != '.') {
        for (k = j; k <= m; k += (k & -k)) R[i][k]++;
      }
  }
  for (j = 1; j <= m; j++) {
    for (i = 1; i <= n; i++)
      if (grid[i][j] != '.') {
        for (k = i; k <= n; k += (k & -k)) C[j][k]++;
      }
  }
}
void ini2() {
  int i, j;
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++) {
      r[i][j] = R[i][j];
    }
  for (j = 0; j <= m; j++)
    for (i = 0; i <= n; i++) {
      c[j][i] = C[j][i];
    }
}
int get1(int id, int pos) {
  int ret = 0, i;
  for (i = pos; i; i -= (i & -i)) ret += r[id][i];
  return ret;
}
int get2(int id, int pos) {
  int ret = 0, i;
  for (i = pos; i; i -= (i & -i)) ret += c[id][i];
  return ret;
}
void up1(int id, int pos) {
  int ret = 0, i;
  for (i = pos; i <= m; i += (i & -i)) r[id][i]--;
}
void up2(int id, int pos) {
  int ret = 0, i;
  for (i = pos; i <= n; i += (i & -i)) c[id][i]--;
}
int get(int fx, int fy) {
  int i, j, ret = 0, k, lo, hi, mid, mil;
  ini2();
  while (1) {
    if (fx >= 1 && fx <= n && fy >= 1 && fy <= m) {
      vis[fx][fy] = 1;
      up1(fx, fy);
      up2(fy, fx);
      if (grid[fx][fy] == 'L') {
        lo = 1;
        hi = fy;
        mil = get1(fx, fy);
        if (mil == 0) {
          ret++;
          fy = 0;
          continue;
        }
        while (lo <= hi) {
          mid = (lo + hi) / 2;
          k = get1(fx, mid);
          if (k != mil)
            lo = mid + 1;
          else
            hi = mid - 1;
        }
        fy = lo;
      } else if (grid[fx][fy] == 'R') {
        lo = fy;
        hi = m;
        mil = get1(fx, fy);
        while (lo <= hi) {
          mid = (lo + hi) / 2;
          k = get1(fx, mid);
          if (k == mil)
            lo = mid + 1;
          else
            hi = mid - 1;
        }
        fy = lo;
      } else if (grid[fx][fy] == 'U') {
        lo = 1;
        hi = fx;
        mil = get2(fy, fx);
        if (mil == 0) {
          ret++;
          fx = 0;
          continue;
        }
        while (lo <= hi) {
          mid = (lo + hi) / 2;
          k = get2(fy, mid);
          if (k != mil)
            lo = mid + 1;
          else
            hi = mid - 1;
        }
        fx = lo;
      } else {
        lo = fx;
        hi = n;
        mil = get2(fy, fx);
        while (lo <= hi) {
          mid = (lo + hi) / 2;
          k = get2(fy, mid);
          if (k == mil)
            lo = mid + 1;
          else
            hi = mid - 1;
        }
        fx = lo;
      }
      ret++;
    } else {
      break;
    }
  }
  return ret;
}
int main() {
  memset(vis, 0, sizeof(vis));
  int i, j;
  scanf("%d %d", &n, &m);
  N = n + 10;
  M = m + 10;
  grid = new char *[N];
  R = new int *[N];
  r = new int *[N];
  C = new int *[M];
  c = new int *[M];
  for (i = 0; i <= N; i++) {
    grid[i] = new char[M];
    R[i] = new int[M];
    r[i] = new int[M];
  }
  for (i = 0; i <= M; i++) {
    C[i] = new int[N];
    c[i] = new int[N];
  }
  for (i = 1; i <= n; i++) {
    scanf("%s", grid[i] + 1);
  }
  ini();
  int mx = 0;
  int cnt = 0, now;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (grid[i][j] == '.' || vis[i][j]) continue;
      now = get(i, j);
      if (now > mx) {
        mx = now;
        cnt = 1;
      } else if (now == mx)
        cnt++;
    }
  printf("%d %d\n", mx, cnt);
  return 0;
}
