#include <bits/stdc++.h>
using namespace std;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
int N, M;
char C[5005];
int R[5005], L[5005], D[5005], U[5005];
map<pair<int, int>, int> ID;
string B[5005];
int dfs(int id) {
  if (id == 0) return 0;
  int pr = R[id];
  int pl = L[id];
  int pu = U[id];
  int pd = D[id];
  R[L[id]] = R[id];
  L[R[id]] = L[id];
  U[D[id]] = U[id];
  D[U[id]] = D[id];
  int ret;
  if (C[id] == 'L') ret = dfs(L[id]) + 1;
  if (C[id] == 'R') ret = dfs(R[id]) + 1;
  if (C[id] == 'U') ret = dfs(U[id]) + 1;
  if (C[id] == 'D') ret = dfs(D[id]) + 1;
  R[pl] = id;
  L[pr] = id;
  U[pd] = id;
  D[pu] = id;
  return ret;
}
int main() {
  cin >> N >> M;
  for (int i = (0); i <= (N - 1); i++) cin >> B[i];
  int c = 0;
  for (int i = (0); i <= (N - 1); i++)
    for (int j = (0); j <= (M - 1); j++) {
      ID[{i, j}] = ++c;
      C[c] = B[i][j];
    }
  for (int i = (0); i <= (N - 1); i++) {
    int p = 0;
    for (int j = (0); j <= (M - 1); j++) {
      L[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
    p = 0;
    for (int j = (M - 1); j >= (0); j--) {
      R[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
  }
  for (int j = (0); j <= (M - 1); j++) {
    int p = 0;
    for (int i = (0); i <= (N - 1); i++) {
      U[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
    p = 0;
    for (int i = (N - 1); i >= (0); i--) {
      D[ID[{i, j}]] = p;
      if (B[i][j] != '.') p = ID[{i, j}];
    }
  }
  int ans = 0, times = 1;
  for (int i = (0); i <= (N - 1); i++)
    for (int j = (0); j <= (M - 1); j++)
      if (B[i][j] != '.') {
        int x = dfs(ID[{i, j}]);
        if (x > ans) ans = x, times = 0;
        if (x >= ans) times++;
      }
  cout << ans << " " << times;
}
