#include <bits/stdc++.h>
using namespace std;
int N, M;
struct Node {
  int next[4];
  Node() {}
  Node(int a, int b, int c, int d) {
    next[0] = a;
    next[1] = b;
    next[2] = c;
    next[3] = d;
  }
};
Node* arr[5000];
char ch[5000][5001];
bool isValid(int y, int x) {
  if (y >= 0 && y < N && x >= 0 && x < M) {
    return true;
  } else {
    return false;
  }
}
bool isY(int y) { return y >= 0 && y < N; }
bool isX(int x) { return x >= 0 && x < M; }
int Count(int y, int x, int way) {
  if (!isValid(y, x)) {
    return 0;
  } else {
    int pos;
    if (ch[y][x] == 'U') {
      pos = 0;
    } else if (ch[y][x] == 'D') {
      pos = 1;
    } else if (ch[y][x] == 'L') {
      pos = 2;
    } else if (ch[y][x] == 'R') {
      pos = 3;
    } else {
      pos = way;
    }
    if (isY(arr[y][x].next[0])) {
      int index = arr[y][x].next[0];
      arr[index][x].next[1] = arr[y][x].next[1];
    }
    if (isY(arr[y][x].next[1])) {
      int index = arr[y][x].next[1];
      arr[index][x].next[0] = arr[y][x].next[0];
    }
    if (isX(arr[y][x].next[2])) {
      int index = arr[y][x].next[2];
      arr[y][index].next[3] = arr[y][x].next[3];
    }
    if (isX(arr[y][x].next[3])) {
      int index = arr[y][x].next[3];
      arr[y][index].next[2] = arr[y][x].next[2];
    }
    if (pos % 4 < 2) {
      return (ch[y][x] != '.') + Count(arr[y][x].next[pos], x, pos);
    } else {
      return (ch[y][x] != '.') + Count(y, arr[y][x].next[pos], pos);
    }
  }
}
void reset() {
  for (int(n) = 0; n < (int)N; n++) {
    for (int(m) = 0; m < (int)M; m++) {
      arr[n][m] = Node(n - 1, n + 1, m - 1, m + 1);
    }
  }
}
int main() {
  scanf("%d", &N);
  ;
  scanf("%d", &M);
  ;
  for (int(n) = 0; n < (int)N; n++) {
    arr[n] = new Node[M];
    scanf("%s", ch[n]);
  }
  int MAX = -1;
  int counter = 0;
  for (int(n) = 0; n < (int)N; n++) {
    for (int(m) = 0; m < (int)M; m++) {
      if (ch[n][m] != '.') {
        reset();
        int val = Count(n, m, 0);
        if (val == MAX) {
          counter++;
        } else if (val > MAX) {
          MAX = val;
          counter = 1;
        }
      }
    }
  }
  printf("%d %d\n", MAX, counter);
}
