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;
char gride[5010];
vector<vector<char> > grid;
vector<vector<int> > pesq, pesq2;
vector<vector<int> > pdir, pdir2;
vector<vector<int> > pcima, pcima2;
vector<vector<int> > pbaxo, pbaxo2;
void apaga(int i, int j) {
  if (pesq2[i][j] != -1) pdir2[i][pesq2[i][j]] = pdir2[i][j];
  if (pdir2[i][j] != -1) pesq2[i][pdir2[i][j]] = pesq2[i][j];
  if (pcima2[i][j] != -1) pbaxo2[pcima2[i][j]][j] = pbaxo2[i][j];
  if (pbaxo2[i][j] != -1) pcima2[pbaxo2[i][j]][j] = pcima2[i][j];
}
int simula(int i, int j) {
  if (grid[i][j] == 'U') {
    int k = pcima2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(k, j);
  }
  if (grid[i][j] == 'D') {
    int k = pbaxo2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(k, j);
  }
  if (grid[i][j] == 'L') {
    int k = pesq2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(i, k);
  }
  if (grid[i][j] == 'R') {
    int k = pdir2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(i, k);
  }
  return 0;
}
int main() {
  scanf("%d %d", &n, &m);
  grid.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%s", gride);
    grid[i].resize(m);
    for (int j = 0; j < m; j++) grid[i][j] = gride[j];
  }
  pesq.resize(n);
  pdir.resize(n);
  pcima.resize(n);
  pbaxo.resize(n);
  for (int i = 0; i < n; i++) {
    pesq[i].resize(m);
    pdir[i].resize(m);
    pcima[i].resize(m);
    pbaxo[i].resize(m);
    int atu = -1;
    for (int j = 0; j < m; j++)
      if (grid[i][j] != '.') {
        pesq[i][j] = atu;
        atu = j;
      }
    atu = -1;
    for (int j = m - 1; j >= 0; j--)
      if (grid[i][j] != '.') {
        pdir[i][j] = atu;
        atu = j;
      }
  }
  for (int j = 0; j < m; j++) {
    int atu = -1;
    for (int i = 0; i < n; i++)
      if (grid[i][j] != '.') {
        pcima[i][j] = atu;
        atu = i;
      }
    atu = -1;
    for (int i = n - 1; i >= 0; i--)
      if (grid[i][j] != '.') {
        pbaxo[i][j] = atu;
        atu = i;
      }
  }
  int best = 0;
  int qts = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (grid[i][j] != '.') {
        pcima2 = pcima;
        pbaxo2 = pbaxo;
        pesq2 = pesq;
        pdir2 = pdir;
        int t = simula(i, j);
        if (t == best)
          qts++;
        else if (t > best) {
          best = t;
          qts = 1;
        }
      }
  printf("%d %d\n", best, qts);
  return 0;
}
