#include <bits/stdc++.h>
using namespace std;
int N, M;
char A[6000][6000];
vector<int> U[6000];
vector<int> D[6000];
vector<int> R[6000];
vector<int> L[6000];
int hv[6000][6000];
int mx, cnt;
int process(int sx, int sy) {
  for (int Ni = 0; Ni < N; Ni++) {
    U[Ni].clear();
    D[Ni].clear();
    R[Ni].clear();
    L[Ni].clear();
    for (int Mi = 0; Mi < M; Mi++) {
      if (A[Ni][Mi] != '.')
        hv[Ni][Mi] = true;
      else
        hv[Ni][Mi] = false;
      U[Ni].push_back(Ni - 1), D[Ni].push_back(Ni + 1);
      R[Ni].push_back(Mi + 1), L[Ni].push_back(Mi - 1);
    }
  }
  int _cnt = 0;
  int nx = sx, ny = sy;
  while (0 <= nx && nx < N && 0 <= ny && ny < M) {
    _cnt++;
    hv[nx][ny] = false;
    if (A[nx][ny] == 'U') {
      int px = nx, py = ny;
      while (0 <= px && px < N && !hv[px][py]) px = U[px][py];
      U[nx][ny] = px;
      nx = px;
    } else if (A[nx][ny] == 'D') {
      int px = nx, py = ny;
      while (0 <= px && px < N && !hv[px][py]) px = D[px][py];
      D[nx][ny] = px;
      nx = px;
    } else if (A[nx][ny] == 'R') {
      int px = nx, py = ny;
      while (0 <= py && py < M && !hv[px][py]) py = R[px][py];
      R[nx][ny] = py;
      ny = py;
    } else if (A[nx][ny] == 'L') {
      int px = nx, py = ny;
      while (0 <= py && py < M && !hv[px][py]) py = L[px][py];
      L[nx][ny] = py;
      ny = py;
    }
  }
  return _cnt;
}
int main() {
  scanf("%d %d", &N, &M);
  for (int Ni = 0; Ni < N; Ni++) scanf("%s", A[Ni]);
  for (int Ni = 0; Ni < N; Ni++)
    for (int Mi = 0; Mi < M; Mi++) {
      if (A[Ni][Mi] != '.') {
        int p = process(Ni, Mi);
        if (p > mx)
          mx = p, cnt = 1;
        else if (p == mx)
          cnt++;
      }
    }
  printf("%d %d\n", mx, cnt);
}
