#include <bits/stdc++.h>
using namespace std;
int d[4];
int nx[5555][4], pr[5555][4];
int cn[5555][4], cp[5555][4];
int a[5555];
int n, m;
inline int go(int k, int l) {
  if (nx[k][l] != -2) return nx[k][l];
  if (k + d[l] >= n * m || k + d[l] < 0 || (l & 1 && (k + d[l]) / m != k / m))
    return nx[k][l] = -1;
  else if (a[k + d[l]] != -1)
    return nx[k][l] = k + d[l];
  else
    return nx[k][l] = go(k + d[l], l);
}
inline int gop(int k, int l) {
  if (pr[k][l] != -2) return pr[k][l];
  if (k - d[l] >= n * m || k - d[l] < 0 || (l & 1 && (k - d[l]) / m != k / m))
    return pr[k][l] = -1;
  else if (a[k - d[l]] != -1)
    return pr[k][l] = k - d[l];
  else
    return pr[k][l] = gop(k - d[l], l);
}
int main() {
  cin >> n >> m;
  d[0] = -m;
  d[1] = 1;
  d[2] = m;
  d[3] = -1;
  for (int(i) = 0; (i) < (n * m); ++(i)) {
    char ch;
    cin >> ch;
    if (ch == '.')
      a[i] = -1;
    else if (ch == 'U')
      a[i] = 0;
    else if (ch == 'R')
      a[i] = 1;
    else if (ch == 'D')
      a[i] = 2;
    else
      a[i] = 3;
    for (int(l) = 0; (l) < (4); ++(l)) nx[i][l] = pr[i][l] = -2;
  }
  for (int(i) = 0; (i) < (n * m); ++(i))
    for (int(l) = 0; (l) < (4); ++(l))
      if (nx[i][l] == -2) go(i, l);
  for (int(i) = 0; (i) < (n * m); ++(i))
    for (int(l) = 0; (l) < (4); ++(l))
      if (pr[i][l] == -2) gop(i, l);
  int ans = 0;
  int cnt = 0;
  for (int(i) = 0; (i) < (n * m); ++(i))
    if (a[i] != -1) {
      memcpy(cn, nx, sizeof(cn));
      memcpy(cp, pr, sizeof(cp));
      int j = i;
      int cur = 0;
      while (j != -1) {
        cur++;
        for (int(dir) = 0; (dir) < (4); ++(dir)) {
          int pp = cp[j][dir];
          int nn = cn[j][dir];
          if (~pp) cn[pp][dir] = nn;
          if (~nn) cp[nn][dir] = pp;
        }
        j = cn[j][a[j]];
      }
      if (cur > ans) {
        ans = cur;
        cnt = 1;
      } else if (cur == ans)
        cnt++;
    }
  cout << ans << " " << cnt << endl;
}
