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>
int n, m, ans;
int L[5010], R[5010], U[5010], D[5010], col[5010], sum[5010], row[5010];
char s[5010][5010];
int node;
void build(int n, int m) {
  int head = 0;
  L[0] = m;
  R[0] = 1;
  for (int i = 1; i <= m; i++) {
    L[i] = i - 1;
    R[i] = (i + 1) % (m + 1);
    col[i] = U[i] = D[i] = i;
    sum[i] = 0;
  }
  node = m;
  for (int i = 1; i <= n; i++) {
    int head = 0;
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '.') continue;
      node++;
      D[U[j]] = node;
      U[node] = U[j];
      D[node] = j;
      U[j] = node;
      if (!head) {
        head = node;
        L[head] = R[head] = head;
      } else {
        L[node] = L[head];
        R[node] = head;
        R[L[node]] = node;
        L[head] = node;
      }
      col[node] = j;
      row[node] = i;
      sum[j]++;
    }
  }
}
void remove(int node) {
  L[R[node]] = L[node];
  R[L[node]] = R[node];
  U[D[node]] = U[node];
  D[U[node]] = D[node];
}
void resume(int node) {
  U[D[node]] = node;
  D[U[node]] = node;
  L[R[node]] = node;
  R[L[node]] = node;
}
void dfs(int id) {
  ans++;
  int x = row[id];
  int y = col[id];
  if (y == 0) {
    x--;
    y = m;
  }
  if (s[x][y] == 'D') {
    if (D[id] > id) {
      remove(id);
      dfs(D[id]);
      resume(id);
    }
  } else if (s[x][y] == 'U') {
    if (U[id] < id) {
      remove(id);
      dfs(U[id]);
      resume(id);
    }
  } else if (s[x][y] == 'L') {
    if (L[id] < id) {
      remove(id);
      dfs(L[id]);
      resume(id);
    }
  } else {
    if (R[id] > id) {
      remove(id);
      dfs(R[id]);
      resume(id);
    }
  }
}
int test(int id) {
  ans = 0;
  dfs(id);
  return ans;
}
int main() {
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
    build(n, m);
    int maxx = 0, num = 1;
    for (int ii = m + 1; ii <= node; ii++) {
      int ans = test(ii);
      if (ans > maxx) {
        maxx = ans;
        num = 1;
      } else if (ans == maxx)
        num++;
    }
    printf("%d %d\n", maxx, num);
  }
  return 0;
}
