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;
long long int power(long long int x, long long int y, long long int p) {
  long long int r = 1;
  x = x % p;
  while (y) {
    if (y & 1) r = r * x % p;
    y = y >> 1;
    x = x * x % p;
  }
  return r;
}
struct node {
  node *l, *r, *u, *d;
  int dir;
  int i, j;
  node() {
    l = r = u = d = NULL;
    i = j = dir = 0;
  }
};
vector<vector<node> > g;
int n, m;
void build() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      g[i][j].i = i, g[i][j].j = j;
      if (i) {
        if (g[i - 1][j].dir)
          g[i][j].u = &g[i - 1][j];
        else
          g[i][j].u = g[i - 1][j].u;
      }
      if (j) {
        if (g[i][j - 1].dir)
          g[i][j].l = &g[i][j - 1];
        else
          g[i][j].l = g[i][j - 1].l;
      }
    }
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--) {
      if (i != n - 1) {
        if (g[i + 1][j].dir)
          g[i][j].d = &g[i + 1][j];
        else
          g[i][j].d = g[i + 1][j].d;
      }
      if (j != m - 1) {
        if (g[i][j + 1].dir)
          g[i][j].r = &g[i][j + 1];
        else
          g[i][j].r = g[i][j + 1].r;
      }
    }
}
void del(node *cur) {
  if (cur->l) cur->l->r = cur->r;
  if (cur->r) cur->r->l = cur->l;
  if (cur->u) cur->u->d = cur->d;
  if (cur->d) cur->d->u = cur->u;
}
long long int solve(int i, int j) {
  long long int ans = 0;
  node *temp = &g[i][j], *cc;
  while (1) {
    ans++;
    if (temp->dir == 1) {
      if (temp->l == NULL) return ans;
      cc = temp->l;
      del(temp);
      temp = cc;
    } else if (temp->dir == 2) {
      if (temp->r == NULL) return ans;
      cc = temp->r;
      del(temp);
      temp = cc;
    } else if (temp->dir == 3) {
      if (temp->u == NULL) return ans;
      cc = temp->u;
      del(temp);
      temp = cc;
    } else if (temp->dir == 4) {
      if (temp->d == NULL) return ans;
      cc = temp->d;
      del(temp);
      temp = cc;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  g.resize(n + 1);
  for (int i = 0; i < n + 1; i++) g[i].resize(m + 1);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char ch;
      cin >> ch;
      if (ch == 'L') g[i][j].dir = 1;
      if (ch == 'R') g[i][j].dir = 2;
      if (ch == 'U') g[i][j].dir = 3;
      if (ch == 'D') g[i][j].dir = 4;
    }
  long long int ans = -1e9, ct = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (!g[i][j].dir) continue;
      build();
      long long int ta = solve(i, j);
      if (ta > ans)
        ans = ta, ct = 1;
      else if (ta == ans)
        ct++;
    }
  cout << ans << " " << ct << '\n';
}
