#include <bits/stdc++.h>
using namespace std;
int b = 0, b1 = 0;
int N, M;
int g[5010];
int delta[5010][5], d2[5010][5];
char c[256];
inline int valid(int x, int y) { return x >= 0 && y >= 0 && x < N && y < M; }
int dir[4][2] = {0, -1, -1, 0, 0, 1, 1, 0};
inline int iabs(int t) { return t > 0 ? t : -t; }
int main() {
  c['L'] = 0;
  c['U'] = 1;
  c['R'] = 2;
  c['D'] = 3;
  c['.'] = -1;
  cin >> N >> M;
  string s;
  for (int i = 0; i < (N); i++) {
    cin >> s;
    for (int j = 0; j < (M); j++) {
      g[(i * M + j)] = c[s[j]];
      for (int k = 0; k < (5); k++) delta[(i * M + j)][k] = 1;
    }
  }
  memcpy(d2, delta, sizeof d2);
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (M); j++) {
      if (g[(i * M + j)] >= 0) {
        memcpy(delta, d2, sizeof d2);
        int now = 0;
        int x = i, y = j;
        while (valid(x, y)) {
          now++;
          int d = g[(x * M + y)];
          int x2 = x, y2 = y, suc = 1;
          delta[(x * M + y)][4] = -1;
          while (1) {
            if (!valid(x2, y2)) {
              suc = 0;
              break;
            }
            if (delta[(x2 * M + y2)][4] != -1 && g[(x2 * M + y2)] != -1) {
              break;
            }
            int dx = delta[(x2 * M + y2)][d];
            x2 += dir[d][0] * dx;
            y2 += dir[d][1] * dx;
          }
          if (!suc) {
            x = -1;
          } else {
            delta[(x * M + y)][d] = iabs(x2 - x) + iabs(y2 - y) + 1;
            x = x2;
            y = y2;
          }
        }
        if (now > b) {
          b = now;
          b1 = 0;
        }
        if (now == b) b1++;
      }
    }
  }
  cout << b << ' ' << b1 << endl;
  return 0;
}
