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;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
char ch[10005];
char chcp[10005];
int dpr[10005][4];
int dpc[10005][4];
int n, m;
int ggg[2000];
int dr[] = {0, 1, 0, -1};
int dc[] = {1, 0, -1, 0};
string grid;
bool inside(int r, int c) { return r >= 0 && r < n && c >= 0 && c < m; }
pair<int, int> move(int r, int c, int ggg) {
  if (!inside(r, c)) return make_pair(r, c);
  if (chcp[r * m + c] != '.') return make_pair(r, c);
  if (dpr[r * m + c][ggg] == -10) {
    dpr[r * m + c][ggg] = r + dr[ggg];
    dpc[r * m + c][ggg] = c + dc[ggg];
  }
  pair<int, int> hasil = move(dpr[r * m + c][ggg], dpc[r * m + c][ggg], ggg);
  dpr[r * m + c][ggg] = hasil.first;
  dpc[r * m + c][ggg] = hasil.second;
  return hasil;
}
int main() {
  ggg['R'] = 0;
  ggg['D'] = 1;
  ggg['L'] = 2;
  ggg['U'] = 3;
  cin >> n >> m;
  int best = 0;
  int ret = 0;
  for (int i = (int)0; i <= (int)n - 1; i++) {
    cin >> grid;
    for (int j = i * m; j < (i + 1) * m; ++j) ch[j] = grid[j - i * m];
  }
  for (int ir = (int)0; ir <= (int)n - 1; ir++)
    for (int ic = (int)0; ic <= (int)m - 1; ic++)
      if (ch[ir * m + ic] != '.') {
        for (int r = (int)0; r <= (int)n * m - 1; r++)
          for (int d = (int)0; d <= (int)3; d++) dpr[r][d] = dpc[r][d] = -10;
        for (int r = (int)0; r <= (int)n * m - 1; r++) chcp[r] = ch[r];
        int moves = 0;
        int r = ir, c = ic;
        while (inside(r, c)) {
          ++moves;
          int a = ggg[(int)chcp[r * m + c]];
          chcp[r * m + c] = '.';
          pair<int, int> p = move(r, c, a);
          r = p.first;
          c = p.second;
        }
        if (moves > best) {
          best = moves;
          ret = 0;
        }
        if (moves == best) ++ret;
      }
  cout << best << " " << ret << endl;
  return 0;
}
