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 head = 0;
const int INF = 1000000;
int n, m;
int O[100005], C[100005], S[100005], Row[100005];
int L[100005], R[100005], U[100005], D[100005];
vector<char> str[100005];
char Dir[100005];
void remove(const int &cur) {
  L[R[cur]] = L[cur];
  R[L[cur]] = R[cur];
  U[D[cur]] = U[cur];
  D[U[cur]] = D[cur];
}
void resume(const int &cur) {
  U[D[cur]] = cur;
  D[U[cur]] = cur;
  L[R[cur]] = cur;
  R[L[cur]] = cur;
}
void dfs(int cur, int &cnt) {
  if (Dir[cur] == 'L') {
    if (C[L[cur]] == 0 || C[L[cur]] >= C[cur]) return;
    remove(cur);
    cnt++;
    dfs(L[cur], cnt);
    resume(cur);
  } else if (Dir[cur] == 'R') {
    if (C[R[cur]] == 0 || C[R[cur]] <= C[cur]) return;
    remove(cur);
    cnt++;
    dfs(R[cur], cnt);
    resume(cur);
  } else if (Dir[cur] == 'U') {
    if (Row[U[cur]] == 0 || Row[U[cur]] >= Row[cur]) return;
    remove(cur);
    cnt++;
    dfs(U[cur], cnt);
    resume(cur);
  } else {
    if (Row[D[cur]] == 0 || Row[D[cur]] <= Row[cur]) return;
    remove(cur);
    cnt++;
    dfs(D[cur], cnt);
    resume(cur);
  }
}
int main() {
  int i, j, cnt, k;
  int Cnum;
  int Rnum;
  char temp[5005];
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = head; i <= m; i++) {
      R[i] = (i + 1) % (m + 1);
      L[i] = (i - 1 + m + 1) % (m + 1);
      U[i] = D[i] = i;
      S[i] = 0;
      Row[i] = C[i] = 0;
    }
    for (i = 1; i <= n; i++) {
      str[i].clear();
      scanf("%s", temp);
      str[i].push_back('#');
      for (j = 0; j < m; j++) str[i].push_back(temp[j]);
    }
    cnt = m + 1;
    for (i = 1; i <= n; i++) {
      Rnum = -1;
      for (j = 1; j <= m; j++) {
        if (str[i][j] == '.') continue;
        Dir[cnt] = str[i][j];
        Cnum = j;
        U[cnt] = U[Cnum];
        D[U[Cnum]] = cnt;
        U[Cnum] = cnt;
        D[cnt] = Cnum;
        Row[cnt] = i;
        C[cnt] = j;
        if (Rnum == -1) {
          L[cnt] = R[cnt] = cnt;
          Rnum = cnt;
        } else {
          L[cnt] = L[Rnum];
          R[L[Rnum]] = cnt;
          L[Rnum] = cnt;
          R[cnt] = Rnum;
        }
        cnt++;
      }
    }
    int ans = 0, count = 0;
    for (i = m + 1; i < cnt; i++) {
      remove(i);
      int temp = 1;
      dfs(i, temp);
      if (temp > ans)
        ans = temp, count = 1;
      else if (temp == ans)
        count++;
      resume(i);
    }
    printf("%d %d\n", ans, count);
  }
  return 0;
}
