#include <bits/stdc++.h>
using namespace std;
int n, m;
int dir[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
unordered_map<char, int> c_to_idx{{'L', 0}, {'U', 1}, {'R', 2}, {'D', 3}};
int is_ok(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
struct Node {
 public:
  pair<int, int> cur;
  pair<int, int> nxt_dir[4];
  Node(int x, int y) : cur{x, y} {
    for (int ctr1 = 0; ctr1 < 4; ++ctr1)
      nxt_dir[ctr1] = {x + dir[ctr1][0], y + dir[ctr1][1]};
  }
  void expand(vector<vector<Node>>& mapa) {
    for (int ctr1 = 0; ctr1 < 4; ++ctr1)
      if (is_ok(nxt_dir[ctr1].first, nxt_dir[ctr1].second))
        mapa[nxt_dir[ctr1].first][nxt_dir[ctr1].second]
            .nxt_dir[(ctr1 + 2) % 4] = nxt_dir[(ctr1 + 2) % 4];
  }
  void compress(vector<vector<Node>>& mapa) {
    for (int ctr1 = 0; ctr1 < 4; ++ctr1)
      if (is_ok(nxt_dir[ctr1].first, nxt_dir[ctr1].second))
        mapa[nxt_dir[ctr1].first][nxt_dir[ctr1].second]
            .nxt_dir[(ctr1 + 2) % 4] = cur;
  }
};
vector<vector<Node>> mat;
vector<string> mapa;
int count(pair<int, int> a) {
  pair<int, int> nxt =
      mat[a.first][a.second].nxt_dir[c_to_idx[mapa[a.first][a.second]]];
  if (!is_ok(nxt.first, nxt.second)) return 1;
  mat[a.first][a.second].expand(mat);
  int rez = 1 + count(nxt);
  mat[a.first][a.second].compress(mat);
  return rez;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  string s;
  for (int ctr1 = 0; ctr1 < n; ++ctr1) cin >> s, mapa.push_back(s);
  for (int ctr1 = 0; ctr1 < n; ++ctr1) {
    vector<Node> tmp;
    for (int ctr2 = 0; ctr2 < m; ++ctr2) tmp.emplace_back(ctr1, ctr2);
    mat.push_back(tmp);
  }
  for (int ctr1 = 0; ctr1 < n; ++ctr1) {
    for (int ctr2 = 0; ctr2 < m; ++ctr2) {
      if (mapa[ctr1][ctr2] == '.') mat[ctr1][ctr2].expand(mat);
    }
  }
  pair<int, int> rez = {0, 0};
  for (int ctr1 = 0; ctr1 < n; ++ctr1) {
    for (int ctr2 = 0; ctr2 < m; ++ctr2) {
      if (mapa[ctr1][ctr2] != '.') {
        int c_rez = count({ctr1, ctr2});
        if (c_rez == rez.first)
          ++rez.second;
        else if (c_rez > rez.first)
          rez = {c_rez, 1};
      }
    }
  }
  cout << rez.first << ' ' << rez.second << '\n';
  return 0;
}
