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;
vector<vector<char> > a, savea;
vector<vector<int> > up, down, __left, __right;
int m, n, cur[5011];
char tmp[100111];
void calc() {
  memset(cur, 0, sizeof cur);
  for (int i = (1), _b = (m); i <= _b; i++) {
    for (int j = (1), _b = (n); j <= _b; j++)
      if (a[i][j] != '.') {
        if (cur[j]) up[i][j] = cur[j];
        cur[j] = i;
      }
  }
  memset(cur, 0, sizeof cur);
  for (int i = (m), _b = (1); i >= _b; i--) {
    for (int j = (1), _b = (n); j <= _b; j++)
      if (a[i][j] != '.') {
        if (cur[j]) down[i][j] = cur[j];
        cur[j] = i;
      }
  }
  memset(cur, 0, sizeof cur);
  for (int j = (1), _b = (n); j <= _b; j++) {
    for (int i = (1), _b = (m); i <= _b; i++)
      if (a[i][j] != '.') {
        if (cur[i]) __left[i][j] = cur[i];
        cur[i] = j;
      }
  }
  memset(cur, 0, sizeof cur);
  for (int j = (n), _b = (1); j >= _b; j--) {
    for (int i = (1), _b = (m); i <= _b; i++)
      if (a[i][j] != '.') {
        if (cur[i]) __right[i][j] = cur[i];
        cur[i] = j;
      }
  }
}
void clear(int u, int v) {
  int x = up[u][v], y = down[u][v];
  if (x) down[x][v] = y;
  if (y) up[y][v] = x;
  x = __left[u][v], y = __right[u][v];
  if (x) __right[u][x] = y;
  if (y) __left[u][y] = x;
  a[u][v] = '.';
}
int main() {
  while (scanf("%d%d\n", &m, &n) == 2) {
    {
      a.resize(m + 5);
      for (int i = 0, _a = (m + 5); i < _a; i++) a[i].resize(n + 5);
    };
    {
      savea.resize(m + 5);
      for (int i = 0, _a = (m + 5); i < _a; i++) savea[i].resize(n + 5);
    };
    {
      up.resize(m + 5);
      for (int i = 0, _a = (m + 5); i < _a; i++) up[i].resize(n + 5);
    };
    {
      down.resize(m + 5);
      for (int i = 0, _a = (m + 5); i < _a; i++) down[i].resize(n + 5);
    };
    {
      __left.resize(m + 5);
      for (int i = 0, _a = (m + 5); i < _a; i++) __left[i].resize(n + 5);
    };
    {
      __right.resize(m + 5);
      for (int i = 0, _a = (m + 5); i < _a; i++) __right[i].resize(n + 5);
    };
    for (int i = (1), _b = (m); i <= _b; i++) {
      gets(tmp);
      for (int j = (1), _b = (n); j <= _b; j++)
        a[i][j] = savea[i][j] = tmp[j - 1];
    }
    calc();
    int res = 0, cnt = 0;
    for (int i = (1), _b = (m); i <= _b; i++)
      for (int j = (1), _b = (n); j <= _b; j++)
        if (a[i][j] != '.') {
          int u = i, v = j;
          int cur = 0;
          while (true) {
            ++cur;
            if (a[u][v] == 'U') {
              if (!up[u][v])
                break;
              else {
                clear(u, v);
                u = up[u][v];
              }
            } else if (a[u][v] == 'D') {
              if (!down[u][v])
                break;
              else {
                clear(u, v);
                u = down[u][v];
              }
            } else if (a[u][v] == 'L') {
              if (!__left[u][v])
                break;
              else {
                clear(u, v);
                v = __left[u][v];
              }
            } else {
              if (!__right[u][v])
                break;
              else {
                clear(u, v);
                v = __right[u][v];
              }
            }
          }
          if (cur > res) {
            res = cur;
            cnt = 1;
          } else if (cur == res)
            ++cnt;
          for (int i = (1), _b = (m); i <= _b; i++)
            for (int j = (1), _b = (n); j <= _b; j++) a[i][j] = savea[i][j];
          calc();
        }
    cout << res << ' ' << cnt << endl;
  }
  return 0;
}
