#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
long long seed = std::chrono::steady_clock::now().time_since_epoch().count();
mt19937_64 rng(seed);
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
long long n, m, k, q, l, r, x, y, z;
const long long template_array_size = 1e6 + 8432;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
long long ans = 0;
const long long dr[4] = {0, 0, 1, -1};
const long long dc[4] = {-1, 1, 0, 0};
long long gv(char c) {
  if (c == 'L') return 0;
  if (c == 'R') return 1;
  if (c == 'D') return 2;
  return 3;
}
bool valid(long long r, long long c) {
  return r >= 0 && r < n && c >= 0 && c < m;
}
void solve(int tc = 0) {
  cin >> n >> m;
  long long mat[n][m];
  for (long long i = 0; i < n; i++) {
    cin >> second;
    for (long long j = 0; j < m; j++) {
      if (second[j] == '.')
        mat[i][j] = -1;
      else
        mat[i][j] = gv(second[j]);
    }
  }
  pair<long long, long long> nxt[n][m][4];
  long long v = -1, cv = 0;
  for (long long sr = 0; sr < n; sr++) {
    for (long long sc = 0; sc < m; sc++) {
      if (mat[sr][sc] == -1) continue;
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
          for (long long d = 0; d < 4; d++) {
            long long ni = i + dr[d], nj = j + dc[d];
            nxt[i][j][d] = make_pair(ni, nj);
          }
        }
      }
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
          if (mat[i][j] == -1) {
            pair<long long, long long> l = nxt[i][j][0], r = nxt[i][j][1];
            if (valid(l.first, l.second)) nxt[l.first][l.second][1] = r;
            if (valid(r.first, r.second)) nxt[r.first][r.second][0] = l;
            pair<long long, long long> d = nxt[i][j][2], u = nxt[i][j][3];
            if (valid(d.first, d.second)) nxt[d.first][d.second][3] = u;
            if (valid(u.first, u.second)) nxt[u.first][u.second][2] = d;
          }
        }
      }
      pair<long long, long long> pos = make_pair(sr, sc);
      long long cnt = 0;
      while (valid(pos.first, pos.second)) {
        pair<long long, long long> l = nxt[pos.first][pos.second][0],
                                   r = nxt[pos.first][pos.second][1];
        if (valid(l.first, l.second)) nxt[l.first][l.second][1] = r;
        if (valid(r.first, r.second)) nxt[r.first][r.second][0] = l;
        pair<long long, long long> d = nxt[pos.first][pos.second][2],
                                   u = nxt[pos.first][pos.second][3];
        if (valid(d.first, d.second)) nxt[d.first][d.second][3] = u;
        if (valid(u.first, u.second)) nxt[u.first][u.second][2] = d;
        pos = nxt[pos.first][pos.second][mat[pos.first][pos.second]];
        ++cnt;
      }
      if (cnt > v) {
        v = cnt;
        cv = 1;
      } else if (cnt == v)
        ++cv;
    }
  }
  cout << v << " " << cv << '\n';
}
int main() {
  { ios_base::sync_with_stdio(false); }
  { cin.tie(NULL); }
  cout << setprecision(12) << fixed;
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}
