#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;
}
