#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, u, d, x, y;
  void init() { l = r = u = d = x = y = 0; }
};
node tmp[5010], p[5010];
vector<char> G[5010], a[5010];
vector<int> pos[5010];
int n, m, size;
int ans, sum, cnt;
int left(int x, int y) {
  for (int i = y - 1; i >= 0; i--) {
    if (G[x][i] != '.') return pos[x][i];
  }
  return -1;
}
int right(int x, int y) {
  for (int i = y + 1; i < m; i++) {
    if (G[x][i] != '.') return pos[x][i];
  }
  return -1;
}
int up(int x, int y) {
  for (int i = x - 1; i >= 0; i--) {
    if (G[i][y] != '.') return pos[i][y];
  }
  return -1;
}
int down(int x, int y) {
  for (int i = x + 1; i < n; i++) {
    if (G[i][y] != '.') return pos[i][y];
  }
  return -1;
}
void Delete(int id) {
  tmp[tmp[id].l].r = tmp[id].r;
  tmp[tmp[id].r].l = tmp[id].l;
  tmp[tmp[id].u].d = tmp[id].d;
  tmp[tmp[id].d].u = tmp[id].u;
}
void gao(int x, int y) {
  int i, j, id;
  for (i = 1; i <= size; i++) tmp[i] = p[i];
  id = pos[x][y];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) G[i][j] = a[i][j];
  }
  while (id != -1) {
    sum++;
    x = tmp[id].x;
    y = tmp[id].y;
    Delete(id);
    if (G[x][y] == 'L')
      id = tmp[id].l;
    else if (G[x][y] == 'R')
      id = tmp[id].r;
    else if (G[x][y] == 'U')
      id = tmp[id].u;
    else if (G[x][y] == 'D')
      id = tmp[id].d;
    else
      break;
    G[x][y] = '.';
  }
}
int main() {
  int i, j;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 0; i < n; i++) {
      G[i].clear();
      G[i].resize(m);
      pos[i].clear();
      pos[i].resize(m);
      a[i].clear();
      a[i].resize(m);
    }
    size = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        scanf(" %c", &G[i][j]);
        a[i][j] = G[i][j];
        if (a[i][j] != '.') {
          pos[i][j] = ++size;
          p[size].x = i;
          p[size].y = j;
        } else
          pos[i][j] = 0;
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == '.') continue;
        p[pos[i][j]].l = left(i, j);
        p[pos[i][j]].r = right(i, j);
        p[pos[i][j]].u = up(i, j);
        p[pos[i][j]].d = down(i, j);
      }
    }
    ans = cnt = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == '.') continue;
        sum = 0;
        gao(i, j);
        if (sum > ans) {
          ans = sum;
          cnt = 1;
        } else if (sum == ans)
          cnt++;
      }
    }
    printf("%d %d\n", ans, cnt);
  }
  return 0;
}
