#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
int d[5001], n, m;
pair<int, int> p[5001][5];
int d1[5001];
pair<int, int> p1[5001][5];
void sP(int x, int y, int k, pair<int, int> a) { p[x * m + y][k] = a; }
pair<int, int> gP(int x, int y, int k) { return p[x * m + y][k]; }
void sD(int x, int y, int a) { d[x * m + y] = a; }
int gD(int x, int y) { return d[x * m + y]; }
void sP1(int x, int y, int k, pair<int, int> a) { p1[x * m + y][k] = a; }
pair<int, int> gP1(int x, int y, int k) { return p1[x * m + y][k]; }
void sD1(int x, int y, int a) { d1[x * m + y] = a; }
int gD1(int x, int y) { return d1[x * m + y]; }
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == 'R')
        sD(i, j, 0);
      else if (s[j] == 'U')
        sD(i, j, 1);
      else if (s[j] == 'L')
        sD(i, j, 2);
      else if (s[j] == 'D')
        sD(i, j, 3);
      else
        sD(i, j, -1);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int d = 0; d < 4; d++) {
        int x = i + dx[d], y = j + dy[d];
        while (0 <= x && x < n && 0 <= y && y < m) {
          if (gD(x, y) >= 0) break;
          x += dx[d];
          y += dy[d];
        }
        if (0 <= x && x < n && 0 <= y && y < m) {
          sP(i, j, d, make_pair(x, y));
        } else
          sP(i, j, d, make_pair(-1, -1));
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int d = gD(i, j);
      if (d < 0) continue;
      for (int x = 0; x < n * m; x++) {
        for (int y = 0; y < 4; y++) p1[x][y] = p[x][y];
      }
      pair<int, int> cur = make_pair(i, j);
      int res = 0;
      while (cur.first >= 0) {
        res++;
        int d = gD(cur.first, cur.second);
        pair<int, int> next = gP1(cur.first, cur.second, d);
        for (int k = 0; k < 4; k++) {
          pair<int, int> q = gP1(cur.first, cur.second, k);
          if (q.first >= 0)
            sP1(q.first, q.second, (k + 2) % 4,
                gP1(cur.first, cur.second, (k + 2) % 4));
        }
        cur = next;
      }
      ans.push_back(res);
    }
  }
  sort(ans.begin(), ans.end());
  int K = 0;
  for (int i = 0; i < (int)ans.size(); i++)
    if (ans[i] == ans.back()) K++;
  cout << ans.back() << ' ' << K << endl;
  return 0;
}
