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 N, M;
struct Node {
  int next[4];
  Node() {}
  Node(int a, int b, int c, int d) {
    next[0] = a;
    next[1] = b;
    next[2] = c;
    next[3] = d;
  }
};
Node* arr[5000];
char ch[5000][5001];
bool isValid(int y, int x) {
  if (y >= 0 && y < N && x >= 0 && x < M) {
    return true;
  } else {
    return false;
  }
}
bool isY(int y) { return y >= 0 && y < N; }
bool isX(int x) { return x >= 0 && x < M; }
int Count(int y, int x, int way) {
  if (!isValid(y, x)) {
    return 0;
  } else {
    int pos;
    if (ch[y][x] == 'U') {
      pos = 0;
    } else if (ch[y][x] == 'D') {
      pos = 1;
    } else if (ch[y][x] == 'L') {
      pos = 2;
    } else if (ch[y][x] == 'R') {
      pos = 3;
    } else {
      pos = way;
    }
    if (isY(arr[y][x].next[0])) {
      int index = arr[y][x].next[0];
      arr[index][x].next[1] = arr[y][x].next[1];
    }
    if (isY(arr[y][x].next[1])) {
      int index = arr[y][x].next[1];
      arr[index][x].next[0] = arr[y][x].next[0];
    }
    if (isX(arr[y][x].next[2])) {
      int index = arr[y][x].next[2];
      arr[y][index].next[3] = arr[y][x].next[3];
    }
    if (isX(arr[y][x].next[3])) {
      int index = arr[y][x].next[3];
      arr[y][index].next[2] = arr[y][x].next[2];
    }
    if (pos % 4 < 2) {
      return (ch[y][x] != '.') + Count(arr[y][x].next[pos], x, pos);
    } else {
      return (ch[y][x] != '.') + Count(y, arr[y][x].next[pos], pos);
    }
  }
}
void reset() {
  for (int(n) = 0; n < (int)N; n++) {
    for (int(m) = 0; m < (int)M; m++) {
      arr[n][m] = Node(n - 1, n + 1, m - 1, m + 1);
    }
  }
}
int main() {
  scanf("%d", &N);
  ;
  scanf("%d", &M);
  ;
  for (int(n) = 0; n < (int)N; n++) {
    arr[n] = new Node[M];
    scanf("%s", ch[n]);
  }
  int MAX = -1;
  int counter = 0;
  for (int(n) = 0; n < (int)N; n++) {
    for (int(m) = 0; m < (int)M; m++) {
      reset();
      int val = Count(n, m, 0);
      if (val == MAX) {
        counter++;
      } else if (val > MAX) {
        MAX = val;
        counter = 1;
      }
    }
  }
  printf("%d %d\n", MAX, counter);
}
