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;
int in[500 * 500];
int co;
int m, n;
int read() {
  memset(in, 0, sizeof in);
  scanf("%d%d", &m, &n);
  getchar();
  char ch;
  co = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      ch = getchar();
      if (ch == 'U')
        in[co++] = 1;
      else if (ch == 'L')
        in[co++] = 2;
      else if (ch == 'D')
        in[co++] = 3;
      else if (ch == 'R')
        in[co++] = 4;
      else
        in[co++] = 0;
    }
    getchar();
  }
}
int res(int nn, int list1[500 * 500]) {
  int num = 0;
  int flag = 0;
  while (list1[nn]) {
    if (nn < 0 || nn > co) break;
    if (list1[nn] == 1) {
      num++;
      list1[nn] = 0;
      nn = nn - n;
      while (!list1[nn]) {
        nn -= n;
        if (nn < 0) break;
      }
    } else if (list1[nn] == 2) {
      num++;
      list1[nn] = 0;
      nn--;
      while (!list1[nn]) {
        nn--;
        if (!(nn % n)) {
          flag = 1;
          break;
        }
      }
    } else if (list1[nn] == 3) {
      num++;
      list1[nn] = 0;
      nn += n;
      while (!list1[nn]) {
        nn += n;
        if (nn > co) break;
      }
    } else {
      num++;
      list1[nn] = 0;
      nn++;
      while (!list1[nn]) {
        nn++;
        if ((!(nn % n)) && (!list1[nn])) break;
      }
    }
    if (flag == 1) {
      break;
    }
  }
  return num;
}
inline int initial(int m, int n, int in1[500 * 500]) {
  int k = 1;
  int kk = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) in1[k++] = in[kk++];
  }
}
int main() {
  read();
  int max_num = -1, out = 0;
  for (int i = 1; i < co; i++) {
    int in1[500 * 500];
    memset(in1, 0, sizeof in1);
    initial(m, n, in1);
    int tmp = res(i, in1);
    if (max_num == tmp) {
      out++;
    } else if (tmp > max_num)
      max_num = tmp;
  }
  printf("%d %d", max_num, out);
}
