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 std::abs;
using std::bitset;
using std::cerr;
using std::cin;
using std::cout;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using ld = long double;
template <typename T>
void _dbg(const char* s, T h) {
  cerr << s << " = " << h << "\n";
}
template <typename T, typename... Ts>
void _dbg(const char* s, T h, Ts... t) {
  int b = 0;
  while (((b += *s == '(') -= *s == ')') != 0 || *s != ',') cerr << *s++;
  cerr << " = " << h << ",";
  _dbg(s + 1, t...);
}
struct init {
  init() {
    cin.tie(0);
    std::iostream::sync_with_stdio(0);
    cout << std::fixed << std::setprecision(10);
    cerr << std::fixed << std::setprecision(5);
  }
  ~init() {}
} init;
template <typename T, typename U>
void upx(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
void upn(T& x, U y) {
  if (x > y) x = y;
}
const ll N = 5000;
struct kal {
  char go;
  ll u = -1, d = -1, l = -1, r = -1;
} v[N];
char a[N][N];
ll first[N][N];
kal second[N];
void remove(ll x) {
  if (second[x].u != -1) second[second[x].u].d = second[x].d;
  if (second[x].d != -1) second[second[x].d].u = second[x].u;
  if (second[x].r != -1) second[second[x].r].l = second[x].l;
  if (second[x].l != -1) second[second[x].l].r = second[x].r;
}
int32_t main() {
  ll n, m;
  cin >> n >> m;
  ll z = 0;
  for (ll i = 0; i < (n); ++i)
    for (ll j = 0; j < (m); ++j) {
      cin >> a[i][j];
      if (a[i][j] != '.') {
        v[z].go = a[i][j];
        first[i][j] = z++;
      }
    }
  for (ll i = 0; i < (n); ++i)
    for (ll j = 0; j < (m); ++j) {
      if (a[i][j] == '.') continue;
      for (ll k = i + 1; v[first[i][j]].d == -1 && k < n; ++k)
        if (a[k][j] != '.') v[first[i][j]].d = first[k][j];
      for (ll k = i - 1; v[first[i][j]].u == -1 && k >= 0; --k)
        if (a[k][j] != '.') v[first[i][j]].u = first[k][j];
      for (ll k = j + 1; v[first[i][j]].r == -1 && k < m; ++k)
        if (a[i][k] != '.') v[first[i][j]].r = first[i][k];
      for (ll k = j - 1; v[first[i][j]].l == -1 && k >= 0; --k)
        if (a[i][k] != '.') v[first[i][j]].l = first[i][k];
    }
  ll mx = 0, cmx = 0;
  for (ll i = 0; i < (z); ++i) {
    for (ll j = 0; j < (z); ++j) second[j] = v[j];
    ll u = i, cur = 0;
    while (u >= 0) {
      cur++;
      ll go;
      if (second[u].go == 'U') go = second[u].u;
      if (second[u].go == 'D') go = second[u].d;
      if (second[u].go == 'L') go = second[u].l;
      if (second[u].go == 'R') go = second[u].r;
      remove(u);
      u = go;
    }
    if (cur > mx) mx = cur, cmx = 0;
    if (mx == cur) cmx++;
  }
  cout << mx << ' ' << cmx << '\n';
  return 0;
}
