#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int inf = 5100;
typedef struct a {
  int pos, num;
} per;
short n, m, si[maxn][maxn], ans, ctt;
short tl, tr, tu, td, l[maxn][maxn], r[maxn][maxn], up[maxn][maxn],
    down[maxn][maxn];
void change(int x, int y) {
  tl = l[x][y], tr = r[x][y], tu = up[x][y], td = down[x][y];
  if (tl != inf) r[x][tl] = tr;
  if (tr != inf) l[x][tr] = tl;
  if (td != inf) up[td][y] = tu;
  if (tu != inf) down[tu][y] = td;
}
void go_back(int x, int y, int ttl, int ttr, int ttu, int ttd) {
  if (ttl != inf) r[x][ttl] = y;
  if (ttr != inf) l[x][ttr] = y;
  if (ttd != inf) up[ttd][y] = x;
  if (ttu != inf) down[ttu][y] = x;
}
void print() {
  cout << "TEST\n";
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << l[i][j] << ' ';
    }
    cout << "\n";
  }
}
void dfs(int x, int y, int cnt) {
  if (x == inf || y == inf) {
    if (cnt == ans)
      ctt++;
    else if (cnt > ans) {
      ans = cnt;
      ctt = 1;
    }
    return;
  }
  change(x, y);
  int ttl = tl, ttr = tr, ttu = tu, ttd = td;
  if (si[x][y] == 0)
    dfs(up[x][y], y, cnt + 1);
  else if (si[x][y] == 1)
    dfs(down[x][y], y, cnt + 1);
  else if (si[x][y] == 2)
    dfs(x, l[x][y], cnt + 1);
  else
    dfs(x, r[x][y], cnt + 1);
  go_back(x, y, ttl, ttr, ttu, ttd);
  return;
}
int main() {
  cin >> n >> m;
  char tc;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> tc;
      if (tc == '.')
        si[i][j] = -1;
      else if (tc == 'U')
        si[i][j] = 0;
      else if (tc == 'D')
        si[i][j] = 1;
      else if (tc == 'L')
        si[i][j] = 2;
      else
        si[i][j] = 3;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int last = inf;
    for (int j = 1; j <= m; ++j) {
      if (si[i][j] != -1) {
        l[i][j] = last;
        last = j;
      }
    }
    last = inf;
    for (int j = m; j >= 1; --j) {
      if (si[i][j] != -1) {
        r[i][j] = last;
        last = j;
      }
    }
  }
  for (int j = 1; j <= m; ++j) {
    int last = inf;
    for (int i = 1; i <= n; ++i) {
      if (si[i][j] != -1) {
        up[i][j] = last;
        last = i;
      }
    }
    last = inf;
    for (int i = n; i >= 1; --i) {
      if (si[i][j] != -1) {
        down[i][j] = last;
        last = i;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (si[i][j] != -1) dfs(i, j, 0);
    }
  }
  cout << ans << ' ' << ctt;
  return 0;
}
