#include <bits/stdc++.h>
using namespace std;
const int maxn = 5001;
struct gtr {
  int x;
  int y;
};
int m, n, i, j, res, x, y, ll, rr, xt, yt, h, k, sl;
int tren[maxn], duoi[maxn], trai[maxn], phai[maxn], up[maxn], down[maxn],
    leftt[maxn], rightt[maxn];
string s[5001];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    s[i] = " " + s[i];
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      ll = (i - 1) * m + j;
      if (i - 1 == 0)
        tren[ll] = 0;
      else if (s[i - 1][j] == '.')
        tren[ll] = tren[(i - 2) * m + j];
      else {
        tren[ll] = (i - 2) * m + j;
      }
      if (j - 1 == 0)
        trai[ll] = 0;
      else if (s[i][j - 1] == '.')
        trai[ll] = trai[(i - 1) * m + j - 1];
      else {
        trai[ll] = (i - 1) * m + j - 1;
      }
    }
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      ll = (i - 1) * m + j;
      if (i + 1 > n)
        duoi[ll] = 0;
      else if (s[i + 1][j] == '.')
        duoi[ll] = duoi[i * m + j];
      else {
        duoi[ll] = i * m + j;
      }
      if (j + 1 > m)
        phai[ll] = 0;
      else if (s[i][j + 1] == '.')
        phai[ll] = phai[(i - 1) * m + j + 1];
      else {
        phai[ll] = (i - 1) * m + j + 1;
      }
    }
  res = 0;
  sl = 1;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (s[i][j] != '.') {
        for (x = 1; x <= n; x++)
          for (y = 1; y <= m; y++) {
            ll = (x - 1) * m + y;
            up[ll] = tren[ll];
            down[ll] = duoi[ll];
            leftt[ll] = trai[ll];
            rightt[ll] = phai[ll];
          }
        rr = 0;
        x = i;
        y = j;
        do {
          ll = (x - 1) * m + y;
          if (s[x][y] == 'U')
            xt = up[ll];
          else if (s[x][y] == 'L')
            xt = leftt[ll];
          else if (s[x][y] == 'R')
            xt = rightt[ll];
          else
            xt = down[ll];
          rr++;
          yt = leftt[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (rightt[ll] == 0)
              rightt[yt] = 0;
            else
              rightt[yt] = rightt[ll];
          }
          yt = rightt[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (leftt[ll] == 0)
              leftt[yt] = 0;
            else
              leftt[yt] = leftt[ll];
          }
          yt = up[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (down[ll] == 0)
              down[yt] = 0;
            else
              down[yt] = down[ll];
          }
          yt = down[ll];
          h = (yt - 1) / m + 1;
          k = (yt - 1) % m + 1;
          if (h != 0) {
            if (up[ll] == 0)
              up[yt] = 0;
            else
              up[yt] = up[ll];
          }
          x = (xt - 1) / m + 1;
          y = (xt - 1) % m + 1;
        } while (xt != 0);
        if (res < rr) {
          res = rr;
          sl = 1;
        } else if (res == rr)
          sl++;
      }
  cout << res << " " << sl;
}
