#include <bits/stdc++.h>
using namespace std;
int n, m, ans, cnt;
vector<string> str;
vector<vector<pair<int, int> > > chi[4], par[4];
void build(int x, int y, int parx, int pary, int dir) {
  if (x < 0 || y < 0 || x == n || y == m) return;
  int nparx = parx, npary = pary;
  if (str[x][y] != '.') {
    if (parx != -1) {
      chi[dir][parx][pary] = pair<int, int>(x, y);
      par[dir][x][y] = pair<int, int>(parx, pary);
    }
    nparx = x, npary = y;
  }
  if (dir == 0)
    build(x - 1, y, nparx, npary, dir);
  else if (dir == 1)
    build(x + 1, y, nparx, npary, dir);
  else if (dir == 2)
    build(x, y - 1, nparx, npary, dir);
  else
    build(x, y + 1, nparx, npary, dir);
}
void init() {
  str.resize(n);
  for (int i = int(0); i <= int(n - 1); i++) cin >> str[i];
  for (int i = int(0); i <= int(3); i++) {
    chi[i].resize(n);
    par[i].resize(n);
    for (int j = int(0); j <= int(n - 1); j++) {
      chi[i][j].resize(m);
      par[i][j].resize(m);
      for (int k = int(0); k <= int(m - 1); k++) {
        chi[i][j][k] = pair<int, int>(-1, -1);
        par[i][j][k] = pair<int, int>(-1, -1);
      }
    }
  }
  for (int i = int(0); i <= int(m - 1); i++) {
    for (int j = int(n - 1); j >= int(0); j--) {
      if (str[j][i] != '.') {
        build(j, i, -1, -1, 0);
        break;
      }
    }
    for (int j = int(0); j <= int(n - 1); j++) {
      if (str[j][i] != '.') {
        build(j, i, -1, -1, 1);
        break;
      }
    }
  }
  for (int i = int(0); i <= int(n - 1); i++) {
    for (int j = int(m - 1); j >= int(0); j--) {
      if (str[i][j] != '.') {
        build(i, j, -1, -1, 2);
        break;
      }
    }
    for (int j = int(0); j <= int(m - 1); j++) {
      if (str[i][j] != '.') {
        build(i, j, -1, -1, 3);
        break;
      }
    }
  }
  ans = 0;
  cnt = 0;
}
void recurse(int x, int y, int dep) {
  if (dep > ans) {
    ans = dep;
    cnt = 1;
  } else if (dep == ans)
    cnt++;
  pair<int, int> nex;
  if (str[x][y] == 'U')
    nex = chi[0][x][y];
  else if (str[x][y] == 'D')
    nex = chi[1][x][y];
  else if (str[x][y] == 'L')
    nex = chi[2][x][y];
  else
    nex = chi[3][x][y];
  for (int i = int(0); i <= int(3); i++) {
    if (par[i][x][y].first != -1)
      chi[i][par[i][x][y].first][par[i][x][y].second] = chi[i][x][y];
    if (chi[i][x][y].first != -1)
      par[i][chi[i][x][y].first][chi[i][x][y].second] = par[i][x][y];
  }
  if (nex.first != -1) recurse(nex.first, nex.second, dep + 1);
  for (int i = int(0); i <= int(3); i++) {
    if (par[i][x][y].first != -1)
      chi[i][par[i][x][y].first][par[i][x][y].second] = pair<int, int>(x, y);
    if (chi[i][x][y].first != -1)
      par[i][chi[i][x][y].first][chi[i][x][y].second] = pair<int, int>(x, y);
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  init();
  for (int i = int(0); i <= int(n - 1); i++) {
    for (int j = int(0); j <= int(m - 1); j++) {
      if (str[i][j] != '.') recurse(i, j, 1);
    }
  }
  printf("%d %d\n", ans, cnt);
  return 0;
}
