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;
struct chip {
  int l;
  int r;
  int u;
  int d;
};
vector<char> a[5005];
vector<chip> link1[5005], link2[5005];
int n, m, kq, res;
void nhap() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  char x;
  for (int i = 1; i <= n; ++i) a[i].push_back(' ');
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> x;
      a[i].push_back(x);
    }
  for (int i = 1; i <= n; ++i) a[i].push_back(' ');
  for (int i = 0; i <= m + 1; ++i) {
    a[0].push_back(' ');
    a[n + 1].push_back(' ');
  }
  for (int i = 0; i <= n + 1; ++i)
    for (int j = 0; j <= m + 1; ++j) {
      chip x;
      x.l = 0;
      x.r = 0;
      x.u = 0;
      x.d = 0;
      link1[i].push_back(x);
      link2[i].push_back(x);
    }
}
void prep() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j] != '.') {
        int l = j - 1, r = j + 1, u = i - 1, d = i + 1;
        while (a[i][l] == '.' && l > 0) --l;
        while (a[i][r] == '.' && r <= m) ++r;
        while (a[u][j] == '.' && u > 0) --u;
        while (a[d][j] == '.' && d <= n) ++d;
        link1[i][j].l = l;
        link1[i][j].r = r;
        link1[i][j].u = u;
        link1[i][j].d = d;
      }
}
void xl(int x, int y) {
  int dem = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) link2[i][j] = link1[i][j];
  while (a[x][y] != '.' && x > 0 && x <= n && y > 0 && y <= m) {
    ++dem;
    int l = link2[x][y].l, r = link2[x][y].r, u = link2[x][y].u,
        d = link2[x][y].d;
    link2[x][l].r = r;
    link2[x][r].l = l;
    link2[u][y].d = d;
    link2[d][y].u = u;
    if (a[x][y] == 'L')
      y = l;
    else if (a[x][y] == 'R')
      y = r;
    else if (a[x][y] == 'U')
      x = u;
    else if (a[x][y] == 'D')
      x = d;
  }
  kq = max(kq, dem);
}
void xl1(int x, int y) {
  int dem = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) link2[i][j] = link1[i][j];
  while (a[x][y] != '.' && x > 0 && x <= n && y > 0 && y <= m) {
    ++dem;
    int l = link2[x][y].l, r = link2[x][y].r, u = link2[x][y].u,
        d = link2[x][y].d;
    link2[x][l].r = r;
    link2[x][r].l = l;
    link2[u][y].d = d;
    link2[d][y].u = u;
    if (a[x][y] == 'L')
      y = l;
    else if (a[x][y] == 'R')
      y = r;
    else if (a[x][y] == 'U')
      x = u;
    else if (a[x][y] == 'D')
      x = d;
  }
  if (dem == kq) ++res;
}
int main() {
  nhap();
  prep();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j] != '.') xl(i, j);
  cout << kq << ' ';
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j] != '.') xl1(i, j);
  cout << res;
  return 0;
}
