#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long n, k, t, m, q, flag = 0;
long long power(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  t = 1;
  while (t--) {
    cin >> n >> m;
    char a[n][m];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> a[i][j];
    long long rown[n][m], rowp[n][m], coln[n][m], colp[n][m];
    int ans = 0, maxcount = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (a[i][j] == '.') continue;
        for (int i1 = 0; i1 < n; i1++)
          for (int j1 = 0; j1 < m; j1++)
            rown[i1][j1] = i1 + 1, rowp[i1][j1] = i1 - 1, coln[i1][j1] = j1 + 1,
            colp[i1][j1] = j1 - 1;
        for (int i1 = 0; i1 < n; i1++)
          for (int j1 = 0; j1 < m; j1++)
            if (a[i1][j1] == '.') {
              if (rowp[i1][j1] != -1) rown[rowp[i1][j1]][j1] = rown[i1][j1];
              if (rown[i1][j1] != n) rowp[rown[i1][j1]][j1] = rowp[i1][j1];
              if (colp[i1][j1] != -1) coln[i1][colp[i1][j1]] = coln[i1][j1];
              if (coln[i1][j1] != m) colp[i1][coln[i1][j1]] = colp[i1][j1];
            }
        long long count = 0;
        int i1 = i, j1 = j;
        count++;
        while (1) {
          if (rowp[i1][j1] != -1) rown[rowp[i1][j1]][j1] = rown[i1][j1];
          if (rown[i1][j1] != n) rowp[rown[i1][j1]][j1] = rowp[i1][j1];
          if (colp[i1][j1] != -1) coln[i1][colp[i1][j1]] = coln[i1][j1];
          if (coln[i1][j1] != m) colp[i1][coln[i1][j1]] = colp[i1][j1];
          if (a[i1][j1] == 'D') {
            if (rown[i1][j1] == n)
              break;
            else {
              count++;
              i1 = rown[i1][j1];
            }
          } else if (a[i1][j1] == 'U') {
            if (rowp[i1][j1] == -1)
              break;
            else {
              count++;
              i1 = rowp[i1][j1];
            }
          } else if (a[i1][j1] == 'R') {
            if (coln[i1][j1] == m)
              break;
            else {
              count++;
              j1 = coln[i1][j1];
            }
          } else if (a[i1][j1] == 'L') {
            if (colp[i1][j1] == -1)
              break;
            else {
              count++;
              j1 = colp[i1][j1];
            }
          }
        }
        if (count == ans)
          maxcount++;
        else if (count > ans)
          ans = count, maxcount = 1;
      }
    cout << ans << " " << maxcount;
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
