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;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
inline void read(long long *a, long long n) {
  for (long long i = 0; i < n; i++) a[i] = in();
}
template <class blank>
inline void out(blank x) {
  cout << x << "\n";
  exit(0);
}
template <class blank>
inline void smin(blank &a, blank b) {
  a = min(a, b);
}
template <class blank>
inline void smax(blank &a, blank b) {
  a = max(a, b);
}
const long long maxn = 1e5 + 10;
const long long maxm = 1e6 + 10;
const long long maxlg = 21;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 10;
const long long SQ = 317 + 5;
struct node {
  node *right, *left, *up, *down;
  char ch;
  node() { right = left = up = down = NULL; }
} * cell[5005], *cpcell[5005];
string s[maxn];
long long res, cnt, n, m;
inline long long dfs(node *node) {
  long long ret = 1;
  if (node->left != NULL) node->left->right = node->right;
  if (node->right != NULL) node->right->left = node->left;
  if (node->down != NULL) node->down->up = node->up;
  if (node->up != NULL) node->up->down = node->down;
  if (node->ch == 'U') {
    if (node->up != NULL) return ret + dfs(node->up);
  }
  if (node->ch == 'D') {
    if (node->down != NULL) {
      return ret + dfs(node->down);
    }
  }
  if (node->ch == 'L')
    if (node->left != NULL) return ret + dfs(node->left);
  if (node->ch == 'R')
    if (node->right != NULL) return ret + dfs(node->right);
  return ret;
}
int32_t main() {
  n = in(), m = in();
  for (long long i = 0; i < n; i++) {
    s[i] = get();
    for (long long j = 0; j < m; j++) {
      cell[i * m + j] = new node();
      cell[i * m + j]->ch = s[i][j];
      cpcell[i * m + j] = new node();
    }
  }
  for (long long startX = 0; startX < n; startX++) {
    for (long long startY = 0; startY < m; startY++) {
      if (s[startX][startY] == '.') continue;
      for (long long i = 0; i < n; i++) {
        long long preLeft = -1;
        for (long long j = 0; j < m; j++) {
          if (s[i][j] == '.') continue;
          long long nodeId = i * m + j;
          if (preLeft + 1) {
            cell[preLeft]->right = cell[nodeId];
            cell[nodeId]->left = cell[preLeft];
          }
          preLeft = nodeId;
        }
      }
      for (long long j = 0; j < m; j++) {
        long long preUp = -1;
        for (long long i = 0; i < n; i++) {
          if (s[i][j] == '.') continue;
          long long nodeId = i * m + j;
          if (preUp + 1)
            cell[preUp]->down = cell[nodeId], cell[nodeId]->up = cell[preUp];
          preUp = nodeId;
        }
      }
      long long val = dfs(cell[startX * m + startY]);
      if (val == res)
        cnt++;
      else if (val > res)
        cnt = 1, res = val;
    }
  }
  cout << res << " " << cnt << "\n";
}
