#include <bits/stdc++.h>
using namespace std;
enum { UP, DOWN, LEFT, RIGHT };
const int MAX = 15500;
struct Node {
  int dir;
  Node* pt[4];
} node[MAX], *cur, *row[MAX], *col[MAX], *st[MAX];
char s[MAX];
int r, c, top;
int getDir(char c) {
  switch (c) {
    case 'U':
      return UP;
    case 'D':
      return DOWN;
    case 'L':
      return LEFT;
    case 'R':
      return RIGHT;
  }
  return -1;
}
void init() {
  cur = node;
  top = 0;
  for (int i = 0; i < r; i++) {
    row[i] = cur++;
    row[i]->pt[LEFT] = row[i]->pt[RIGHT] = row[i];
    row[i]->pt[UP] = row[i]->pt[DOWN] = NULL;
    row[i]->dir = -1;
  }
  for (int i = 0; i < c; i++) {
    col[i] = cur++;
    col[i]->pt[UP] = col[i]->pt[DOWN] = col[i];
    col[i]->pt[LEFT] = col[i]->pt[RIGHT] = NULL;
    col[i]->dir = -1;
  }
}
Node* add(int x, int y, int dir) {
  cur->pt[RIGHT] = row[x]->pt[RIGHT];
  cur->pt[LEFT] = row[x];
  cur->pt[DOWN] = col[y]->pt[DOWN];
  cur->pt[UP] = col[y];
  cur->pt[LEFT]->pt[RIGHT] = cur;
  cur->pt[RIGHT]->pt[LEFT] = cur;
  cur->pt[UP]->pt[DOWN] = cur;
  cur->pt[DOWN]->pt[UP] = cur;
  cur->dir = dir;
  return cur++;
}
int dfs(Node* t) {
  if (t->dir == -1) return 0;
  t->pt[LEFT]->pt[RIGHT] = t->pt[RIGHT];
  t->pt[RIGHT]->pt[LEFT] = t->pt[LEFT];
  t->pt[UP]->pt[DOWN] = t->pt[DOWN];
  t->pt[DOWN]->pt[UP] = t->pt[UP];
  int ret = dfs(t->pt[t->dir]) + 1;
  t->pt[LEFT]->pt[RIGHT] = t;
  t->pt[RIGHT]->pt[LEFT] = t;
  t->pt[UP]->pt[DOWN] = t;
  t->pt[DOWN]->pt[UP] = t;
  return ret;
}
int main() {
  int ret, cnt;
  while (scanf("%d%d", &r, &c) == 2) {
    ret = -1;
    cnt = 0;
    init();
    for (int i = 0; i < r; i++) {
      scanf("%s", &s[i * c]);
    }
    for (int i = r - 1; i >= 0; i--) {
      for (int j = c - 1; j >= 0; j--) {
        if (s[i * c + j] != '.') st[top++] = add(i, j, getDir(s[i * c + j]));
      }
    }
    for (int i = 0; i < top; i++) {
      int sub = dfs(st[i]);
      if (sub > ret) {
        ret = sub;
        cnt = 1;
      } else if (sub == ret) {
        cnt++;
      }
    }
    printf("%d %d\n", ret, cnt);
  }
  return 0;
}
