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;
class chip_info {
 public:
  int lef, rig;
};
vector<vector<char> > game;
vector<vector<chip_info> > strng, stolb, cpstrng, cpstolb;
int N, M;
void copy() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      strng[i][j] = cpstrng[i][j];
      stolb[j][i] = cpstolb[j][i];
    }
}
int modeling(int x, int y) {
  int moves = 0;
  while (x >= 0 && y >= 0) {
    moves++;
    if (strng[x][y].lef != -1) strng[x][strng[x][y].lef].rig = strng[x][y].rig;
    if (strng[x][y].rig != -1) strng[x][strng[x][y].rig].lef = strng[x][y].lef;
    if (stolb[y][x].lef != -1) stolb[y][stolb[y][x].lef].rig = stolb[y][x].rig;
    if (stolb[y][x].rig != -1) stolb[y][stolb[y][x].rig].lef = stolb[y][x].lef;
    if (game[x][y] == 'L')
      y = strng[x][y].lef;
    else if (game[x][y] == 'R')
      y = strng[x][y].rig;
    else if (game[x][y] == 'U')
      x = stolb[y][x].lef;
    else
      x = stolb[y][x].rig;
  }
  copy();
  return moves;
}
int main() {
  cin >> N >> M;
  game.resize(N + 1);
  strng.resize(N + 1);
  stolb.resize(M + 1);
  cpstrng.resize(N + 1);
  cpstolb.resize(M + 1);
  for (int i = 0; i < N; i++) game[i].resize(M + 1);
  for (int i = 0; i < N; i++) {
    strng[i].resize(M + 1);
    cpstrng[i].resize(M + 1);
  }
  for (int j = 0; j < M; j++) {
    stolb[j].resize(N + 1);
    cpstolb[j].resize(N + 1);
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) cin >> game[i][j];
  int numchip = -1;
  for (int i = 0; i < N; i++) {
    numchip = -1;
    for (int j = 0; j < M; j++)
      if (game[i][j] != '.') {
        strng[i][j].lef = numchip;
        if (numchip != -1) strng[i][numchip].rig = j;
        numchip = j;
      }
    if (numchip != -1) strng[i][numchip].rig = -1;
  }
  for (int j = 0; j < M; j++) {
    numchip = -1;
    for (int i = 0; i < N; i++)
      if (game[i][j] != '.') {
        stolb[j][i].lef = numchip;
        if (numchip != -1) stolb[j][numchip].rig = i;
        numchip = i;
      }
    if (numchip != -1) stolb[j][numchip].rig = -1;
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      cpstrng[i][j] = strng[i][j];
      cpstolb[j][i] = stolb[j][i];
    }
  int t = 0, maxi = 0, kol = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      t = 0;
      if (game[i][j] != '.') t = modeling(i, j);
      if (t > maxi) {
        maxi = t;
        kol = 1;
      } else if (t == maxi)
        kol++;
    }
  cout << maxi << " " << kol;
  return 0;
}
