#include <bits/stdc++.h>
using namespace std;
bool O[100000];
int r, c, to[4][100000];
char mp[100000];
inline int node(int i, int j) { return i * (c + 2) + j; }
inline int gd(char c) {
  switch (c) {
    case 'R':
      return 0;
    case 'D':
      return 1;
    case 'L':
      return 2;
    case 'U':
      return 3;
  }
}
int ans, cnt;
inline void rm(int v) {
  for (int i = 0; i < 4; ++i) to[(i + 2) % 4][to[i][v]] = to[(i + 2) % 4][v];
}
inline void re(int v) {
  for (int i = 0; i < 4; ++i) to[(i + 2) % 4][to[i][v]] = v;
}
void dfs(int v, int dep) {
  if (O[v]) {
    if (ans < dep)
      ans = dep, cnt = 1;
    else if (ans == dep)
      ++cnt;
    return;
  }
  rm(v);
  dfs(to[gd(mp[v])][v], dep + 1);
  re(v);
}
int main() {
  while (scanf("%d%d", &r, &c) != EOF) {
    ans = 0, cnt = 0;
    fill(O, O + (r + 2) * (c + 2), false);
    fill(mp, mp + (r + 2) * (c + 2), 0);
    for (int i = 1; i <= r; ++i)
      for (int j = 1; j <= c; ++j) scanf(" %c", mp + node(i, j));
    for (int i = 0; i < r + 2; ++i) O[node(i, 0)] = O[node(i, c + 1)] = true;
    for (int j = 0; j < c + 2; ++j) O[node(0, j)] = O[node(r + 1, j)] = true;
    for (int i = 1; i <= r; ++i) {
      for (int j = 1; j < c + 2; ++j)
        if (mp[node(i, j - 1)] != '.')
          to[2][node(i, j)] = node(i, j - 1);
        else
          to[2][node(i, j)] = to[2][node(i, j - 1)];
      for (int j = c; j >= 0; --j)
        if (mp[node(i, j + 1)] != '.')
          to[0][node(i, j)] = node(i, j + 1);
        else
          to[0][node(i, j)] = to[0][node(i, j + 1)];
    }
    for (int j = 1; j <= c; ++j) {
      for (int i = 1; i < r + 2; ++i)
        if (mp[node(i - 1, j)] != '.')
          to[3][node(i, j)] = node(i - 1, j);
        else
          to[3][node(i, j)] = to[3][node(i - 1, j)];
      for (int i = r; i >= 0; --i)
        if (mp[node(i + 1, j)] != '.')
          to[1][node(i, j)] = node(i + 1, j);
        else
          to[1][node(i, j)] = to[1][node(i + 1, j)];
    }
    for (int i = 1; i <= r; ++i)
      for (int j = 1; j <= c; ++j)
        if (mp[node(i, j)] != '.') dfs(node(i, j), 0);
    printf("%d %d\n", ans, cnt);
  }
  return 0;
}
