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, ans, cnt;
vector<string> str;
vector<vector<pair<int, int> > > chi[4], par[4];
void build(int x, int y, int parx, int pary, int dir) {
  if (x < 0 || y < 0 || x == n || y == m) return;
  int nparx = parx, npary = pary;
  if (str[x][y] != '.') {
    if (parx != -1) {
      chi[dir][parx][pary] = pair<int, int>(x, y);
      par[dir][x][y] = pair<int, int>(parx, pary);
    }
    nparx = x, npary = y;
  }
  if (dir == 0)
    build(x - 1, y, nparx, npary, dir);
  else if (dir == 1)
    build(x + 1, y, nparx, npary, dir);
  else if (dir == 2)
    build(x, y - 1, nparx, npary, dir);
  else
    build(x, y + 1, nparx, npary, dir);
}
void init() {
  str.resize(n);
  for (int i = int(0); i <= int(n - 1); i++) cin >> str[i];
  for (int i = int(0); i <= int(3); i++) {
    chi[i].resize(n);
    par[i].resize(n);
    for (int j = int(0); j <= int(n - 1); j++) {
      chi[i][j].resize(m);
      par[i][j].resize(m);
      for (int k = int(0); k <= int(m - 1); k++) {
        chi[i][j][k] = pair<int, int>(-1, -1);
        par[i][j][k] = pair<int, int>(-1, -1);
      }
    }
  }
  for (int i = int(0); i <= int(m - 1); i++) {
    for (int j = int(n - 1); j >= int(0); j--) {
      if (str[j][i] != '.') {
        build(j, i, -1, -1, 0);
        break;
      }
    }
    for (int j = int(0); j <= int(n - 1); j++) {
      if (str[j][i] != '.') {
        build(j, i, -1, -1, 1);
        break;
      }
    }
  }
  for (int i = int(0); i <= int(n - 1); i++) {
    for (int j = int(m - 1); j >= int(0); j--) {
      if (str[i][j] != '.') {
        build(i, j, -1, -1, 2);
        break;
      }
    }
    for (int j = int(0); j <= int(m - 1); j++) {
      if (str[i][j] != '.') {
        build(i, j, -1, -1, 3);
        break;
      }
    }
  }
  ans = 0;
  cnt = 0;
}
void recurse(int x, int y, int dep) {
  if (dep > ans) {
    ans = dep;
    cnt = 1;
  } else if (dep == ans)
    cnt++;
  pair<int, int> nex;
  if (str[x][y] == 'U')
    nex = chi[0][x][y];
  else if (str[x][y] == 'D')
    nex = chi[1][x][y];
  else if (str[x][y] == 'L')
    nex = chi[2][x][y];
  else
    nex = chi[3][x][y];
  for (int i = int(0); i <= int(3); i++) {
    if (par[i][x][y].first != -1)
      chi[i][par[i][x][y].first][par[i][x][y].second] = chi[i][x][y];
    if (chi[i][x][y].first != -1)
      par[i][chi[i][x][y].first][chi[i][x][y].second] = par[i][x][y];
  }
  if (nex.first != -1) recurse(nex.first, nex.second, dep + 1);
  for (int i = int(0); i <= int(3); i++) {
    if (par[i][x][y].first != -1)
      chi[i][par[i][x][y].first][par[i][x][y].second] = pair<int, int>(x, y);
    if (chi[i][x][y].first != -1)
      par[i][chi[i][x][y].first][chi[i][x][y].second] = pair<int, int>(x, y);
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  init();
  for (int i = int(0); i <= int(n - 1); i++) {
    for (int j = int(0); j <= int(m - 1); j++) {
      if (str[i][j] != '.') recurse(i, j, 1);
    }
  }
  printf("%d %d\n", ans, cnt);
  return 0;
}
