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>
int a[5010], d[5010][4];
int n, m, w;
int ans, num;
int used[5010];
int main() {
  int i, j, k;
  int s;
  char c;
  scanf("%d%d", &n, &m);
  while (scanf("%c", &c) != EOF) {
    if (c == 'U')
      a[w++] = 0;
    else if (c == 'R')
      a[w++] = 1;
    else if (c == 'D')
      a[w++] = 2;
    else if (c == 'L')
      a[w++] = 3;
    else if (c == '.')
      a[w++] = 4;
  }
  for (i = 0; i < w; i++) {
    memset(used, 0, sizeof(used));
    memset(d, 0, sizeof(d));
    if (a[i] > 3) continue;
    s = 1;
    used[i] = 1;
    j = i;
    while (1) {
      if (a[j] == 0) {
        k = d[j][0] + m;
        while (j - k >= 0) {
          if (!used[j - k] && a[j - k] < 4) break;
          k = k + m + d[j - k][0];
        }
        if (j - k < 0) break;
        d[j][0] = k;
        j = j - k;
        used[j] = 1;
        s++;
      } else if (a[j] == 1) {
        k = d[j][1] + 1;
        while ((j % m) + k < m) {
          if (!used[j + k] && a[j + k] < 4) break;
          k = k + 1 + d[j + k][1];
        }
        if ((j % m) + k >= m) break;
        d[j][1] = k;
        j = j + k;
        used[j] = 1;
        s++;
      } else if (a[j] == 2) {
        k = d[j][2] + m;
        while (j + k < w) {
          if (!used[j + k] && a[j + k] < 4) break;
          k = k + m + d[j + k][2];
        }
        if (j + k >= w) break;
        d[j][2] = k;
        j = j + k;
        used[j] = 1;
        s++;
      } else if (a[j] == 3) {
        k = d[j][3] + 1;
        while ((j % m) - k >= 0) {
          if (!used[j - k] && a[j - k] < 4) break;
          k = k + 1 + d[j - k][3];
        }
        if ((j % m) - k < 0) break;
        d[j][3] = k;
        j = j - k;
        used[j] = 1;
        s++;
      }
    }
    if (s > ans) {
      ans = s;
      num = 1;
    } else if (s == ans)
      num++;
  }
  printf("%d %d\n", ans, num);
  return 0;
}
