#include <bits/stdc++.h>
using namespace std;
vector<char> a[5001];
vector<int> usl[5011], usr[5011], usd[5011], usu[5011];
vector<int> l[5011], r[5011], d[5011], u[5011];
int n, m;
int dfs(int i, int j, int kol) {
  if (i == 0 || i == n + 1 || j == 0 || j == m + 1) return kol - 1;
  int tt;
  int x, y, z, w;
  x = l[i][j];
  y = r[i][j];
  z = u[i][j];
  w = d[i][j];
  if (x != 0 && x != m + 1) r[i][x] = y;
  if (y != 0 && y != m + 1) l[i][y] = x;
  if (z != 0 && z != n + 1) d[z][j] = w;
  if (w != 0 && w != n + 1) u[w][j] = z;
  int el;
  if (a[i][j] == 'D')
    return dfs(d[i][j], j, kol + 1);
  else if (a[i][j] == 'U')
    return dfs(u[i][j], j, kol + 1);
  else if (a[i][j] == 'L')
    return dfs(i, l[i][j], kol + 1);
  else
    return dfs(i, r[i][j], kol + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, j, nom;
  char x;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m + 3; j++)
      a[i].push_back(0), usl[i].push_back(0), usr[i].push_back(0),
          usu[i].push_back(0), usd[i].push_back(0);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m + 1; j++)
      l[i].push_back(0), r[i].push_back(0), u[i].push_back(0),
          d[i].push_back(0);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> x, a[i][j] = x;
  for (i = 1; i <= n; i++) {
    nom = 0;
    for (j = 1; j <= m; j++) {
      usl[i][j] = nom;
      if (a[i][j] != '.') nom = j;
    }
  }
  for (i = 1; i <= n; i++) {
    nom = m + 1;
    for (j = m; j >= 1; j--) {
      usr[i][j] = nom;
      if (a[i][j] != '.') nom = j;
    }
  }
  for (i = 1; i <= m; i++) {
    nom = 0;
    for (j = 1; j <= n; j++) {
      usu[j][i] = nom;
      if (a[j][i] != '.') nom = j;
    }
  }
  for (i = 1; i <= m; i++) {
    nom = n + 1;
    for (j = n; j >= 1; j--) {
      usd[j][i] = nom;
      if (a[j][i] != '.') nom = j;
    }
  }
  for (int i1 = 1; i1 <= n; i1++)
    for (int j1 = 1; j1 <= m; j1++)
      l[i1][j1] = usl[i1][j1], r[i1][j1] = usr[i1][j1], u[i1][j1] = usu[i1][j1],
      d[i1][j1] = usd[i1][j1];
  int mx = 0, xr = 0, kol = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == '.') continue;
      for (int i1 = 1; i1 <= n; i1++)
        for (int j1 = 1; j1 <= m; j1++)
          l[i1][j1] = usl[i1][j1], r[i1][j1] = usr[i1][j1],
          u[i1][j1] = usu[i1][j1], d[i1][j1] = usd[i1][j1];
      xr = dfs(i, j, 1);
      if (xr > mx) mx = xr, kol = 0;
      if (xr == mx) kol++;
    }
  }
  cout << mx << ' ' << kol << '\n';
}
