#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
inline pair<int, int> dxdy(char c) {
  if (c == 'U') return pair<int, int>(-1, 0);
  if (c == 'D') return pair<int, int>(+1, 0);
  if (c == 'L') return pair<int, int>(0, -1);
  return pair<int, int>(0, +1);
}
int n, m;
vector<string> a;
vector<vector<pair<int, int> > > b;
string s;
int FLAG;
vector<vector<int> > flag;
vector<vector<int> > was;
vector<vector<int> > T;
inline int check(int x, int y) { return (x >= 0 && y >= 0 && x < n && y < m); }
inline void init() {
  cin >> n >> m;
  a.resize(n);
  flag.resize(n);
  T.resize(n);
  was.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> s;
    a[i] = s;
    T[i].resize(m);
    flag[i].assign(m, -1);
    was[i].assign(m, -1);
  }
}
inline int solve(int x, int y) {
  if (a[x][y] == '.') return 0;
  ++FLAG;
  int res = 0;
  for (;;) {
    ++res;
    was[x][y] = FLAG;
    pair<int, int> cur = dxdy(a[x][y]);
    int dx = cur.first;
    int dy = cur.second;
    if (flag[x][y] != FLAG) {
      T[x][y] = 1;
      flag[x][y] = FLAG;
    }
    int nx = x + T[x][y] * dx;
    int ny = y + T[x][y] * dy;
    int ok = 0;
    while (check(nx, ny)) {
      ++T[x][y];
      if (a[nx][ny] != '.' && was[nx][ny] != FLAG) {
        ok = 1;
        x = nx;
        y = ny;
        break;
      }
      if (a[nx][ny] == a[x][y]) {
        int TT = T[nx][ny] - 1;
        T[x][y] += TT;
        nx += (TT + 1) * dx;
        ny += (TT + 1) * dy;
        continue;
      }
      nx += dx;
      ny += dy;
    }
    if (!ok) return res;
  }
  return res;
}
int main() {
  init();
  FLAG = 0;
  int cnt = 0;
  int best = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      int cur = solve(i, j);
      if (cur > best) {
        best = cur;
        cnt = 0;
      }
      if (cur == best) {
        ++cnt;
      }
    }
  printf("%d %d\n", best, cnt);
  return 0;
}
