#include <bits/stdc++.h>
using namespace std;
int n, m;
char gride[5010];
vector<vector<char> > grid;
vector<vector<int> > pesq, pesq2;
vector<vector<int> > pdir, pdir2;
vector<vector<int> > pcima, pcima2;
vector<vector<int> > pbaxo, pbaxo2;
void apaga(int i, int j) {
  if (pesq2[i][j] != -1) pdir2[i][pesq2[i][j]] = pdir2[i][j];
  if (pdir2[i][j] != -1) pesq2[i][pdir2[i][j]] = pesq2[i][j];
  if (pcima2[i][j] != -1) pbaxo2[pcima2[i][j]][j] = pbaxo2[i][j];
  if (pbaxo2[i][j] != -1) pcima2[pbaxo2[i][j]][j] = pcima2[i][j];
}
int simula(int i, int j) {
  if (grid[i][j] == 'U') {
    int k = pcima2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(k, j);
  }
  if (grid[i][j] == 'D') {
    int k = pbaxo2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(k, j);
  }
  if (grid[i][j] == 'L') {
    int k = pesq2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(i, k);
  }
  if (grid[i][j] == 'R') {
    int k = pdir2[i][j];
    if (k == -1) return 1;
    apaga(i, j);
    return 1 + simula(i, k);
  }
  return 0;
}
int main() {
  scanf("%d %d", &n, &m);
  grid.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%s", gride);
    grid[i].resize(m);
    for (int j = 0; j < m; j++) grid[i][j] = gride[j];
  }
  pesq.resize(n);
  pdir.resize(n);
  pcima.resize(n);
  pbaxo.resize(n);
  for (int i = 0; i < n; i++) {
    pesq[i].resize(m);
    pdir[i].resize(m);
    pcima[i].resize(m);
    pbaxo[i].resize(m);
    int atu = -1;
    for (int j = 0; j < m; j++)
      if (grid[i][j] != '.') {
        pesq[i][j] = atu;
        atu = j;
      }
    atu = -1;
    for (int j = m - 1; j >= 0; j--)
      if (grid[i][j] != '.') {
        pdir[i][j] = atu;
        atu = j;
      }
  }
  for (int j = 0; j < m; j++) {
    int atu = -1;
    for (int i = 0; i < n; i++)
      if (grid[i][j] != '.') {
        pcima[i][j] = atu;
        atu = i;
      }
    atu = -1;
    for (int i = n - 1; i >= 0; i--)
      if (grid[i][j] != '.') {
        pbaxo[i][j] = atu;
        atu = i;
      }
  }
  int best = 0;
  int qts = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (grid[i][j] != '.') {
        pcima2 = pcima;
        pbaxo2 = pbaxo;
        pesq2 = pesq;
        pdir2 = pdir;
        int t = simula(i, j);
        if (t == best)
          qts++;
        else if (t > best) {
          best = t;
          qts = 1;
        }
      }
  printf("%d %d\n", best, qts);
  return 0;
}
