#include <bits/stdc++.h>
using namespace std;
const int step[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
const char *s = "LRUD";
int n, m, tot;
char mp[5010][5010];
struct point {
  int x, y;
};
bool valid(point a) {
  if (a.x >= 0 && a.x < n && a.y >= 0 && a.y < m) return 1;
  return 0;
}
int to(int x, int y) { return x * m + y; }
struct str {
  point next[4];
  int dir;
};
str st[5010];
point temp, now, last;
point rec[5010];
int ct;
int go() {
  int i, j, k;
  int k1, k2;
  int p, q;
  ct = 1;
  rec[0] = now;
  while (valid(rec[ct - 1])) {
    k = to(rec[ct - 1].x, rec[ct - 1].y);
    temp = st[k].next[st[k].dir];
    for (i = 0; i < 4; i += 2) {
      if (i == 0)
        j = 1;
      else
        j = 3;
      now = st[k].next[i];
      last = st[k].next[j];
      if (valid(now)) {
        k1 = to(now.x, now.y);
        st[k1].next[j] = last;
      }
      if (valid(last)) {
        k2 = to(last.x, last.y);
        st[k2].next[i] = now;
      }
    }
    rec[ct] = temp;
    ct++;
  }
  int ret = ct - 1;
  ct--;
  while (ct) {
    k = to(rec[ct - 1].x, rec[ct - 1].y);
    temp = st[k].next[st[k].dir];
    for (i = 0; i < 4; i += 2) {
      if (i == 0)
        j = 1;
      else
        j = 3;
      now = st[k].next[i];
      last = st[k].next[j];
      if (valid(now)) {
        k1 = to(now.x, now.y);
        st[k1].next[j] = rec[ct - 1];
      }
      if (valid(last)) {
        k2 = to(last.x, last.y);
        st[k2].next[i] = rec[ct - 1];
      }
    }
    ct--;
  }
  return ret;
}
int main() {
  int i, j, k, o;
  int p, q;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", &mp[i]);
    tot = n * m;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        o = to(i, j);
        for (k = 0; k < 4; k++) {
          p = i + step[k][0];
          q = j + step[k][1];
          temp.x = p;
          temp.y = q;
          while (valid(temp)) {
            if (mp[temp.x][temp.y] != '.') break;
            temp.x += step[k][0];
            temp.y += step[k][1];
          }
          st[o].next[k] = temp;
        }
        for (k = 0; k < 4; k++) {
          if (mp[i][j] == s[k]) {
            st[o].dir = k;
            break;
          }
        }
      }
    }
    int ans = 0;
    int num = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (mp[i][j] == '.') continue;
        now.x = i;
        now.y = j;
        k = go();
        if (k > ans) {
          ans = k;
          num = 1;
        } else if (k == ans) {
          num++;
        }
      }
    }
    printf("%d %d\n", ans, num);
  }
  return 0;
}
