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>
namespace algo {
using namespace std;
const long double PI = 3.141592653589793238462643383279502884L;
const long double E = 2.718281828459045235360287471352662498L;
const long double EPS = 1e-12L;
template <typename T1, typename T2>
T1 bin_pow(T1 a, T2 n) {
  T1 r = 1;
  while (n > 0) {
    if (n & 1) r *= a;
    a *= a;
    n /= 2;
  }
  return r;
}
template <typename T1, typename T2>
T1 bin_pow(T1 a, T2 n, const T1& m) {
  if (m == 1) return 0;
  T1 r = 1;
  while (n > 0) {
    if (n & 1) {
      r *= a;
      r %= m;
    }
    a *= a;
    a %= m;
    n /= 2;
  }
  return r;
}
template <typename T>
T gcd(const T& a, const T& b) {
  if (b == 0) return abs(a);
  return gcd(b, a % b);
}
template <typename T>
T gcd(const T& a, const T& b, T& x, T& y) {
  if (b == 0) {
    x = a < 0 ? -1 : 1;
    y = 0;
    return x * a;
  }
  T d = gcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}
template <typename T>
T lcm(const T& a, const T& b) {
  return abs(a / gcd(a, b) * b);
}
template <typename T>
T mod_add(const T& a, const T& b, const T& m) {
  if (a < m - b) return a + b;
  return a - (m - b);
}
template <typename T>
T mod_sub(const T& a, const T& b, const T& m) {
  if (a < b) return a + (m - b);
  return a - b;
}
template <typename T>
T mod_mul(T a, T b, const T& m) {
  if (b > a) swap(a, b);
  T r = 0;
  while (b > 0) {
    if (b & 1) r = mod_add(r, a, m);
    a = mod_add(a, a, m);
    b /= 2;
  }
  return r;
}
template <typename T1, typename T2>
T1 mod_pow(T1 a, T2 n, const T1& m) {
  if (m == 1) return 0;
  T1 r = 1;
  while (n > 0) {
    if (n & 1) r = mod_mul(r, a, m);
    a = mod_mul(a, a, m);
    n /= 2;
  }
  return r;
}
template <typename T>
T mod_inv(const T& a, const T& m) {
  T x, y;
  T d = gcd(a, m, x, y);
  if (d != 1) return 0;
  if (x < 0) x += m;
  return x;
}
struct Sieve {
  int* lpf = nullptr;
  int* phi = nullptr;
  int size;
  vector<int> primes;
  Sieve(bool calcPhi = false, int n = 0xfffff) : size(n) {
    lpf = new int[size + 1];
    fill(lpf, lpf + size + 1, 0);
    lpf[1] = 1;
    if (calcPhi) {
      phi = new int[size + 1];
      phi[1] = 1;
      for (int i = 2; i <= size; ++i) {
        if (lpf[i] == 0) {
          phi[i] = i - 1;
          lpf[i] = i;
          primes.push_back(i);
        }
        for (int j = 0, t; j < primes.size() && (t = i * primes[j]) <= size;
             ++j) {
          lpf[t] = primes[j];
          if (primes[j] == lpf[i]) {
            phi[t] = phi[i] * primes[j];
            break;
          }
          phi[t] = phi[i] * (primes[j] - 1);
        }
      }
    } else {
      for (int i = 2; i <= size; ++i) {
        if (lpf[i] == 0) {
          lpf[i] = i;
          primes.push_back(i);
        }
        for (int j = 0, t; j < primes.size() && (t = i * primes[j]) <= size;
             ++j) {
          lpf[t] = primes[j];
          if (primes[j] == lpf[i]) break;
        }
      }
    }
  }
  Sieve(int n) : Sieve(false, n) {}
  ~Sieve() {
    delete[] lpf;
    lpf = nullptr;
    delete[] phi;
    phi = nullptr;
  }
};
template <typename T>
T phi(T n) {
  T r = n;
  for (T i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      r -= r / i;
      do {
        n /= i;
      } while (n % i == 0);
    }
  }
  if (n > 1) r -= r / n;
  return r;
}
}  // namespace algo
using namespace std;
using namespace algo;
namespace task {
const int a1[4] = {1, -1, 0, 0}, a2[4] = {0, 0, 1, -1};
struct ww {
  int l, r;
} a[5010], b[5010], c[5010], d[5010];
int i, j, k, n, m, K, an, re;
int h[200], ty[5010], f1[5010], f2[5010];
char p[5010][5010];
inline int find(int x, int y) {
  if (y == 0) return b[x].r;
  if (y == 1) return b[x].l;
  if (y == 2) return a[x].r;
  if (y == 3) return a[x].l;
}
inline void del(int x) {
  if (a[x].l) a[a[x].l].r = a[x].r;
  if (a[x].r) a[a[x].r].l = a[x].l;
  if (b[x].l) b[b[x].l].r = b[x].r;
  if (b[x].r) b[b[x].r].l = b[x].l;
}
int main() {
  h['D'] = 0, h['U'] = 1, h['R'] = 2, h['L'] = 3;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%s", p[i] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (p[i][j] != '.') {
        ty[++K] = h[p[i][j]];
        if (f1[i]) a[f1[i]].r = K, a[K].l = f1[i];
        f1[i] = K;
        if (f2[j]) b[f2[j]].r = K, b[K].l = f2[j];
        f2[j] = K;
      }
  for (j = 1; j <= K; j++) c[j] = a[j], d[j] = b[j];
  for (i = 1; i <= K; i++) {
    int ans = 0, now = i;
    for (j = 1; j <= K; j++) a[j] = c[j], b[j] = d[j];
    for (; now;) {
      int A = find(now, ty[now]);
      del(now);
      ans++;
      now = A;
    }
    if (ans > an)
      an = ans, re = 1;
    else
      re += ans == an;
  }
  printf("%d %d\n", an, re);
  return 0;
}
}  // namespace task
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
  return task::main();
}
