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 b = 0, b1 = 0;
int N, M;
int g[5010];
int delta[5010][5], d2[5010][5];
char c[256];
inline int valid(int x, int y) { return x >= 0 && y >= 0 && x < N && y < M; }
int dir[4][2] = {0, -1, -1, 0, 0, 1, 1, 0};
inline int iabs(int t) { return t > 0 ? t : -t; }
int main() {
  c['L'] = 0;
  c['U'] = 1;
  c['R'] = 2;
  c['D'] = 3;
  c['.'] = -1;
  cin >> N >> M;
  string s;
  for (int i = 0; i < (N); i++) {
    cin >> s;
    for (int j = 0; j < (M); j++) {
      g[(i * M + j)] = c[s[j]];
      for (int k = 0; k < (5); k++) delta[(i * M + j)][k] = 1;
    }
  }
  memcpy(d2, delta, sizeof d2);
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (M); j++) {
      if (g[(i * M + j)] >= 0) {
        memcpy(delta, d2, sizeof d2);
        int now = 0;
        int x = i, y = j;
        while (valid(x, y)) {
          now++;
          int d = g[(x * M + y)];
          int x2 = x, y2 = y, suc = 1;
          delta[(x * M + y)][4] = -1;
          while (1) {
            if (!valid(x2, y2)) {
              suc = 0;
              break;
            }
            if (delta[(x2 * M + y2)][4] != -1 && g[(x2 * M + y2)] != -1) {
              break;
            }
            int dx = delta[(x2 * M + y2)][d];
            x2 += dir[d][0] * dx;
            y2 += dir[d][1] * dx;
          }
          if (!suc) {
            x = -1;
          } else {
            delta[(x * M + y)][d] = iabs(x2 - x) + iabs(y2 - y) + 1;
            x = x2;
            y = y2;
          }
        }
        if (now > b) {
          b = now;
          b1 = 0;
        }
        if (now == b) b1++;
      }
    }
  }
  cout << b << ' ' << b1 << endl;
  return 0;
}
