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 values {
  long long L, R, D, U;
  values() {
    L = -1;
    R = -1;
    D = -1;
    U = -1;
  }
  void debug() { cout << L << " " << R << " " << D << " " << U << "\n"; }
};
const long long N = 5005;
vector<vector<values> > _next;
vector<string> s;
long long helper(long long i, long long j) {
  if (i == -1 or j == -1) return 0;
  if (s[i][j] == '.') assert(0);
  long long l = _next[i][j].L, r = _next[i][j].R, d = _next[i][j].D,
            u = _next[i][j].U;
  if (l != -1) {
    _next[i][l].R = _next[i][j].R;
  }
  if (r != -1) {
    _next[i][r].L = _next[i][j].L;
  }
  if (d != -1) {
    _next[d][j].U = _next[i][j].U;
  }
  if (u != -1) {
    _next[u][j].D = _next[i][j].D;
  }
  long long _i = i, _j = j;
  if (s[i][j] == 'U') {
    _i = u;
  } else if (s[i][j] == 'D') {
    _i = d;
  } else if (s[i][j] == 'R') {
    _j = r;
  } else if (s[i][j] == 'L') {
    _j = l;
  }
  return 1 + helper(_i, _j);
}
void solve() {
  long long n, m;
  cin >> n >> m;
  s.resize(n);
  for (auto &x : s) cin >> x;
  vector<vector<values> > nearest(n, vector<values>(m));
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      if (i != 0) {
        if (s[i - 1][j] != '.') {
          nearest[i][j].U = i - 1;
        } else {
          nearest[i][j].U = nearest[i - 1][j].U;
        }
      }
      if (j != 0) {
        if (s[i][j - 1] != '.') {
          nearest[i][j].L = j - 1;
        } else {
          nearest[i][j].L = nearest[i][j - 1].L;
        }
      }
    }
  }
  for (long long i = n - 1; i >= 0; --i) {
    for (long long j = m - 1; j >= 0; --j) {
      if (i != n - 1) {
        if (s[i + 1][j] != '.') {
          nearest[i][j].D = i + 1;
        } else {
          nearest[i][j].D = nearest[i + 1][j].D;
        }
      }
      if (j != m - 1) {
        if (s[i][j + 1] != '.') {
          nearest[i][j].R = j + 1;
        } else {
          nearest[i][j].R = nearest[i][j + 1].R;
        }
      }
    }
  }
  long long mx = 0, cnt = 0;
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      if (s[i][j] == '.') {
        continue;
      }
      _next = nearest;
      long long ans = helper(i, j);
      if (ans == mx) ++cnt;
      if (ans > mx) mx = ans, cnt = 1;
    }
  }
  cout << mx << " " << cnt << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; ++i) {
    solve();
  }
  return 0;
}
