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;
bool O[100000];
int r, c, to[4][100000];
char mp[100000];
inline int node(int i, int j) { return i * (c + 2) + j; }
inline int gd(char c) {
  switch (c) {
    case 'R':
      return 0;
    case 'D':
      return 1;
    case 'L':
      return 2;
    case 'U':
      return 3;
  }
}
int ans, cnt;
inline void rm(int v) {
  for (int i = 0; i < 4; ++i) to[(i + 2) % 4][to[i][v]] = to[(i + 2) % 4][v];
}
inline void re(int v) {
  for (int i = 0; i < 4; ++i) to[(i + 2) % 4][to[i][v]] = v;
}
void dfs(int v, int dep) {
  if (O[v]) {
    if (ans < dep)
      ans = dep, cnt = 1;
    else if (ans == dep)
      ++cnt;
    return;
  }
  rm(v);
  dfs(to[gd(mp[v])][v], dep + 1);
  re(v);
}
int main() {
  while (scanf("%d%d", &r, &c) != EOF) {
    ans = 0, cnt = 0;
    fill(O, O + (r + 2) * (c + 2), false);
    fill(mp, mp + (r + 2) * (c + 2), 0);
    for (int i = 1; i <= r; ++i)
      for (int j = 1; j <= c; ++j) scanf(" %c", mp + node(i, j));
    for (int i = 0; i < r + 2; ++i) O[node(i, 0)] = O[node(i, c + 1)] = true;
    for (int j = 0; j < c + 2; ++j) O[node(0, j)] = O[node(r + 1, j)] = true;
    for (int i = 1; i <= r; ++i) {
      for (int j = 1; j < c + 2; ++j)
        if (mp[node(i, j - 1)] != '.')
          to[2][node(i, j)] = node(i, j - 1);
        else
          to[2][node(i, j)] = to[2][node(i, j - 1)];
      for (int j = c; j >= 0; --j)
        if (mp[node(i, j + 1)] != '.')
          to[0][node(i, j)] = node(i, j + 1);
        else
          to[0][node(i, j)] = to[0][node(i, j + 1)];
    }
    for (int j = 1; j <= c; ++j) {
      for (int i = 1; i < r + 2; ++i)
        if (mp[node(i - 1, j)] != '.')
          to[3][node(i, j)] = node(i - 1, j);
        else
          to[3][node(i, j)] = to[3][node(i - 1, j)];
      for (int i = r; i >= 0; --i)
        if (mp[node(i + 1, j)] != '.')
          to[1][node(i, j)] = node(i + 1, j);
        else
          to[1][node(i, j)] = to[1][node(i + 1, j)];
    }
    for (int i = 1; i <= r; ++i)
      for (int j = 1; j <= c; ++j)
        if (mp[node(i, j)] != '.') dfs(node(i, j), 0);
    printf("%d %d\n", ans, cnt);
  }
  return 0;
}
