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;
typedef struct node {
  node *L, *R, *U, *D;
  char dir;
} node;
node** mat;
char** str;
int N, M;
void DEL(node* p) {
  p->R->L = p->L;
  p->L->R = p->R;
  p->U->D = p->D;
  p->D->U = p->U;
}
void init() {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      mat[i][j].dir = str[i][j];
      if (i == 0) {
        mat[i][j].U = &mat[N][j];
      } else {
        mat[i][j].U = &mat[i - 1][j];
      }
      if (i == N) {
        mat[i][j].D = &mat[0][j];
      } else {
        mat[i][j].D = &mat[i + 1][j];
      }
      if (j == 0) {
        mat[i][j].L = &mat[i][M];
      } else {
        mat[i][j].L = &mat[i][j - 1];
      }
      if (j == M) {
        mat[i][j].R = &mat[i][0];
      } else {
        mat[i][j].R = &mat[i][j + 1];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if ('.' == str[i][j]) {
        DEL(&mat[i][j]);
      }
    }
  }
}
int main() {
  scanf("%d %d", &N, &M);
  mat = new node*[N + 10];
  str = new char*[N + 10];
  for (int i = 0; i < N + 10; i++) {
    mat[i] = new node[M + 10];
    str[i] = new char[M + 10];
  }
  for (int i = 0; i < N + 4; i++) {
    for (int j = 0; j < M + 4; j++) {
      str[i][j] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    scanf("%s", str[i]);
  }
  int res = 0;
  int cnt = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if ('.' == str[i][j]) continue;
      init();
      node* cur = &mat[i][j];
      int tmp = 0;
      while (cur->dir != 0) {
        tmp++;
        switch (cur->dir) {
          case 'U': {
            cur = cur->U;
            DEL(cur->D);
            break;
          }
          case 'D': {
            cur = cur->D;
            DEL(cur->U);
            break;
          }
          case 'R': {
            cur = cur->R;
            DEL(cur->L);
            break;
          }
          case 'L': {
            cur = cur->L;
            DEL(cur->R);
            break;
          }
        }
      }
      if (res < tmp) {
        res = tmp;
        cnt = 1;
      } else if (res == tmp) {
        cnt++;
      }
    }
  }
  printf("%d %d\n", res, cnt);
  return 0;
}
