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 A[6000][6000];
vector<int> U[6000];
vector<int> D[6000];
vector<int> R[6000];
vector<int> L[6000];
int hv[6000][6000];
int mx, cnt;
int process(int sx, int sy) {
  for (int Ni = 0; Ni < N; Ni++) {
    U[Ni].clear();
    D[Ni].clear();
    R[Ni].clear();
    L[Ni].clear();
    for (int Mi = 0; Mi < M; Mi++) {
      if (A[Ni][Mi] != '.')
        hv[Ni][Mi] = true;
      else
        hv[Ni][Mi] = false;
      U[Ni].push_back(Ni - 1), D[Ni].push_back(Ni + 1);
      R[Ni].push_back(Mi + 1), L[Ni].push_back(Mi - 1);
    }
  }
  int _cnt = 0;
  int nx = sx, ny = sy;
  while (0 <= nx && nx < N && 0 <= ny && ny < M) {
    _cnt++;
    hv[nx][ny] = false;
    if (A[nx][ny] == 'U') {
      int px = nx, py = ny;
      while (0 <= px && px < N && !hv[px][py]) px = U[px][py];
      U[nx][ny] = px;
      nx = px;
    } else if (A[nx][ny] == 'D') {
      int px = nx, py = ny;
      while (0 <= px && px < N && !hv[px][py]) px = D[px][py];
      D[nx][ny] = px;
      nx = px;
    } else if (A[nx][ny] == 'R') {
      int px = nx, py = ny;
      while (0 <= py && py < M && !hv[px][py]) py = R[px][py];
      R[nx][ny] = py;
      ny = py;
    } else if (A[nx][ny] == 'L') {
      int px = nx, py = ny;
      while (0 <= py && py < M && !hv[px][py]) py = L[px][py];
      L[nx][ny] = py;
      ny = py;
    }
  }
  return _cnt;
}
int main() {
  scanf("%d %d", &N, &M);
  for (int Ni = 0; Ni < N; Ni++) scanf("%s", A[Ni]);
  for (int Ni = 0; Ni < N; Ni++)
    for (int Mi = 0; Mi < M; Mi++) {
      if (A[Ni][Mi] != '.') {
        int p = process(Ni, Mi);
        if (p > mx)
          mx = p, cnt = 1;
        else if (p == mx)
          cnt++;
      }
    }
  printf("%d %d\n", mx, cnt);
}
