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;
const int step[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
const char *s = "LRUD";
int n, m, tot;
char mp[5010][5010];
struct point {
  int x, y;
};
bool valid(point a) {
  if (a.x >= 0 && a.x < n && a.y >= 0 && a.y < m) return 1;
  return 0;
}
int to(int x, int y) { return x * m + y; }
struct str {
  point next[4];
  int dir;
};
str st[5010];
point temp, now, last;
point rec[5010];
int ct;
int go() {
  int i, j, k;
  int k1, k2;
  int p, q;
  ct = 1;
  rec[0] = now;
  while (valid(rec[ct - 1])) {
    k = to(rec[ct - 1].x, rec[ct - 1].y);
    temp = st[k].next[st[k].dir];
    for (i = 0; i < 4; i += 2) {
      if (i == 0)
        j = 1;
      else
        j = 3;
      now = st[k].next[i];
      last = st[k].next[j];
      if (valid(now)) {
        k1 = to(now.x, now.y);
        st[k1].next[j] = last;
      }
      if (valid(last)) {
        k2 = to(last.x, last.y);
        st[k2].next[i] = now;
      }
    }
    rec[ct] = temp;
    ct++;
  }
  int ret = ct - 1;
  ct--;
  while (ct) {
    k = to(rec[ct - 1].x, rec[ct - 1].y);
    temp = st[k].next[st[k].dir];
    for (i = 0; i < 4; i += 2) {
      if (i == 0)
        j = 1;
      else
        j = 3;
      now = st[k].next[i];
      last = st[k].next[j];
      if (valid(now)) {
        k1 = to(now.x, now.y);
        st[k1].next[j] = rec[ct - 1];
      }
      if (valid(last)) {
        k2 = to(last.x, last.y);
        st[k2].next[i] = rec[ct - 1];
      }
    }
    ct--;
  }
  return ret;
}
int main() {
  int i, j, k, o;
  int p, q;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", &mp[i]);
    tot = n * m;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        o = to(i, j);
        for (k = 0; k < 4; k++) {
          p = i + step[k][0];
          q = j + step[k][1];
          temp.x = p;
          temp.y = q;
          while (valid(temp)) {
            if (mp[temp.x][temp.y] != '.') break;
            temp.x += step[k][0];
            temp.y += step[k][1];
          }
          st[o].next[k] = temp;
        }
        for (k = 0; k < 4; k++) {
          if (mp[i][j] == s[k]) {
            st[o].dir = k;
            break;
          }
        }
      }
    }
    int ans = 0;
    int num = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (mp[i][j] == '.') continue;
        now.x = i;
        now.y = j;
        k = go();
        if (k > ans) {
          ans = k;
          num = 1;
        } else if (k == ans) {
          num++;
        }
      }
    }
    printf("%d %d\n", ans, num);
  }
  return 0;
}
