#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
vector<vector<vector<int>>> nxt(4);
int n, m;
char grid[5005][5005];
int cnt = 0;
vector<pair<int, int>> rollback;
vector<vector<vector<int>>> base;
int solve(int sx, int sy) {
  int ret = 0;
  while (sx >= 0 && sx < n && sy >= 0 && sy < m) {
    int L = nxt[0][sx][sy];
    int R = nxt[1][sx][sy];
    if (L >= 0) nxt[1][sx][L] = R, rollback.push_back(pair<int, int>(sx, L));
    if (R < m) nxt[0][sx][R] = L, rollback.push_back(pair<int, int>(sx, R));
    int U = nxt[2][sx][sy];
    int D = nxt[3][sx][sy];
    if (D < n) nxt[2][D][sy] = U, rollback.push_back(pair<int, int>(D, sy));
    if (U >= 0) nxt[3][U][sy] = D, rollback.push_back(pair<int, int>(U, sy));
    ret++;
    if (grid[sx][sy] == 'D') {
      sx = nxt[3][sx][sy];
    } else if (grid[sx][sy] == 'R') {
      sy = nxt[1][sx][sy];
    } else if (grid[sx][sy] == 'U') {
      sx = nxt[2][sx][sy];
    } else {
      sy = nxt[0][sx][sy];
    }
  }
  for (int i = 0; i < rollback.size(); i++) {
    int x, y;
    tie(x, y) = rollback[i];
    nxt[0][x][y] = base[0][x][y];
    nxt[1][x][y] = base[1][x][y];
    nxt[2][x][y] = base[2][x][y];
    nxt[3][x][y] = base[3][x][y];
  }
  rollback.clear();
  return ret;
}
int main() {
  srand(time(0));
  scanf("%d%d", &n, &m);
  nxt[0] = vector<vector<int>>(n, vector<int>(m));
  nxt[1] = vector<vector<int>>(n, vector<int>(m));
  nxt[2] = vector<vector<int>>(n, vector<int>(m));
  nxt[3] = vector<vector<int>>(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf(" %c", &grid[i][j]);
  for (int i = 0; i < n; i++) {
    int b4 = -1;
    for (int j = 0; j < m; j++) {
      nxt[0][i][j] = b4;
      if (grid[i][j] != '.') b4 = j;
    }
    b4 = m;
    for (int j = m - 1; j >= 0; --j) {
      nxt[1][i][j] = b4;
      if (grid[i][j] != '.') b4 = j;
    }
  }
  for (int j = 0; j < m; j++) {
    int b4 = -1;
    for (int i = 0; i < n; i++) {
      nxt[2][i][j] = b4;
      if (grid[i][j] != '.') b4 = i;
    }
    b4 = n;
    for (int i = n - 1; i >= 0; --i) {
      nxt[3][i][j] = b4;
      if (grid[i][j] != '.') b4 = i;
    }
  }
  int ans = 0, cnt = 1;
  base = nxt;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (grid[i][j] != '.') {
        int x = solve(i, j);
        if (x > ans) cnt = 0, ans = x;
        if (x == ans) cnt++;
      }
    }
  cout << ans << ' ' << cnt << '\n';
  return 0;
}
