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;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
int N, M;
char C[5005];
int R[5005], L[5005], D[5005], U[5005];
map<pair<int, int>, int> ID;
string B[5005];
int dfs(int id) {
  if (id == 0) return 0;
  int pr = R[id];
  int pl = L[id];
  int pu = U[id];
  int pd = D[id];
  R[L[id]] = R[id];
  L[R[id]] = L[id];
  U[D[id]] = U[id];
  D[U[id]] = D[id];
  int ret;
  if (C[id] == 'L') ret = dfs(L[id]) + 1;
  if (C[id] == 'R') ret = dfs(R[id]) + 1;
  if (C[id] == 'U') ret = dfs(U[id]) + 1;
  if (C[id] == 'D') ret = dfs(D[id]) + 1;
  R[pl] = id;
  L[pr] = id;
  U[pd] = id;
  D[pu] = id;
  return ret;
}
int main() {
  cin >> N >> M;
  for (int i = (0); i <= (N - 1); i++) cin >> B[i];
  int c = 0;
  for (int i = (0); i <= (N - 1); i++)
    for (int j = (0); j <= (M - 1); j++) {
      ID[{i, j}] = ++c;
      C[c] = B[i][j];
    }
  for (int i = (0); i <= (N - 1); i++) {
    int p = 0;
    for (int j = (0); j <= (M - 1); j++) {
      L[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
    p = 0;
    for (int j = (M - 1); j >= (0); j--) {
      R[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
  }
  for (int j = (0); j <= (M - 1); j++) {
    int p = 0;
    for (int i = (0); i <= (N - 1); i++) {
      U[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
    p = 0;
    for (int i = (N - 1); i >= (0); i--) {
      D[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
  }
  int ans = 0, times = 1;
  for (int i = (0); i <= (N - 1); i++)
    for (int j = (0); j <= (M - 1); j++)
      if (B[i][j] != '.') {
        int x = dfs(ID[{i, j}]);
        if (x > ans) ans = x, times = 0;
        if (x >= ans) times++;
      }
  cout << ans << " " << times;
}
