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 INF = 1 << 29;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int m, n, dir[128];
char field[5001];
int prev[5000][4], next[5000][4];
int code(int y, int x) {
  if (0 <= y && y < m && 0 <= x && x < n) return y * n + x;
  return INF;
}
int solve(int id, int k) {
  if (id == INF) return 0;
  int cnt, nextdir;
  if (field[id] == '.') {
    cnt = 0;
    nextdir = k;
  } else {
    cnt = 1;
    nextdir = dir[field[id]];
    for (int i = 0; i < (4); i++) {
      prev[next[id][i]][i] = prev[id][i];
      next[prev[id][i]][i] = next[id][i];
    }
  }
  return cnt + solve(next[id][nextdir], nextdir);
}
int main() {
  dir['R'] = 0;
  dir['U'] = 1;
  dir['L'] = 2;
  dir['D'] = 3;
  scanf("%d%d", &m, &n);
  for (int i = 0; i < (m); i++) scanf("%s", field + n * i);
  int ans = 0, ans2 = 0;
  for (int id = 0; id < (m * n); id++)
    if (field[id] != '.') {
      for (int id2 = 0; id2 < (m * n); id2++) {
        int i = id2 / n, j = id2 % n;
        for (int k = 0; k < (4); k++) {
          prev[id2][k] = code(i - dy[k], j - dx[k]);
          next[id2][k] = code(i + dy[k], j + dx[k]);
        }
      }
      int tmp = solve(id, dir[id]);
      if (ans == tmp)
        ans2++;
      else if (ans < tmp) {
        ans = tmp;
        ans2 = 1;
      }
    }
  printf("%d %d\n", ans, ans2);
  return 0;
}
