#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  char a[n + 1][m + 1];
  pair<int, int> L[n + 1][m + 1], R[n + 1][m + 1], U[n + 1][m + 1],
      D[n + 1][m + 1], LL[n + 1][m + 1], RR[n + 1][m + 1], UU[n + 1][m + 1],
      DD[n + 1][m + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    pair<int, int> cur = make_pair(-1, -1);
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '.') {
        L[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
    cur = make_pair(-1, -1);
    for (int j = m; j >= 1; j--) {
      if (a[i][j] != '.') {
        R[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    pair<int, int> cur = make_pair(-1, -1);
    for (int i = 1; i <= n; i++) {
      if (a[i][j] != '.') {
        U[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
    cur = make_pair(-1, -1);
    for (int i = n; i >= 1; i--) {
      if (a[i][j] != '.') {
        D[i][j] = cur;
        cur = make_pair(i, j);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      UU[i][j] = U[i][j];
      DD[i][j] = D[i][j];
      LL[i][j] = L[i][j];
      RR[i][j] = R[i][j];
    }
  }
  int mx = 0, cur = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '.') {
        for (int ii = 1; ii <= n; ii++) {
          for (int jj = 1; jj <= m; jj++) {
            L[ii][jj] = LL[ii][jj];
            R[ii][jj] = RR[ii][jj];
            U[ii][jj] = UU[ii][jj];
            D[ii][jj] = DD[ii][jj];
          }
        }
        queue<pair<int, int> > q;
        q.push(make_pair(i, j));
        int sum = 0;
        while (!q.empty()) {
          auto it = q.front();
          q.pop();
          sum++;
          if (R[it.first][it.second] != make_pair(-1, -1)) {
            L[R[it.first][it.second].first][R[it.first][it.second].second] =
                L[it.first][it.second];
          }
          if (L[it.first][it.second] != make_pair(-1, -1)) {
            R[L[it.first][it.second].first][L[it.first][it.second].second] =
                R[it.first][it.second];
          }
          if (U[it.first][it.second] != make_pair(-1, -1)) {
            D[U[it.first][it.second].first][U[it.first][it.second].second] =
                D[it.first][it.second];
          }
          if (D[it.first][it.second] != make_pair(-1, -1)) {
            U[D[it.first][it.second].first][D[it.first][it.second].second] =
                U[it.first][it.second];
          }
          if (a[it.first][it.second] == 'L') {
            if (L[it.first][it.second] != make_pair(-1, -1)) {
              q.push(L[it.first][it.second]);
            }
          } else if (a[it.first][it.second] == 'R') {
            if (R[it.first][it.second] != make_pair(-1, -1)) {
              q.push(R[it.first][it.second]);
            }
          } else if (a[it.first][it.second] == 'U') {
            if (U[it.first][it.second] != make_pair(-1, -1)) {
              q.push(U[it.first][it.second]);
            }
          } else {
            if (D[it.first][it.second] != make_pair(-1, -1)) {
              q.push(D[it.first][it.second]);
            }
          }
        }
        if (sum > mx) {
          mx = sum;
          cur = 1;
        } else if (sum == mx) {
          cur++;
        }
      }
    }
  }
  cout << mx << " " << cur;
}
