#include <bits/stdc++.h>
using namespace std;
typedef struct node {
  node *L, *R, *U, *D;
  char dir;
} node;
node** mat;
char** str;
int N, M;
void DEL(node* p) {
  p->R->L = p->L;
  p->L->R = p->R;
  p->U->D = p->D;
  p->D->U = p->U;
}
void init() {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      mat[i][j].dir = str[i][j];
      if (i == 0) {
        mat[i][j].U = &mat[N][j];
      } else {
        mat[i][j].U = &mat[i - 1][j];
      }
      if (i == N) {
        mat[i][j].D = &mat[0][j];
      } else {
        mat[i][j].D = &mat[i + 1][j];
      }
      if (j == 0) {
        mat[i][j].L = &mat[i][M];
      } else {
        mat[i][j].L = &mat[i][j - 1];
      }
      if (j == M) {
        mat[i][j].R = &mat[i][0];
      } else {
        mat[i][j].R = &mat[i][j + 1];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if ('.' == str[i][j]) {
        DEL(&mat[i][j]);
      }
    }
  }
}
int main() {
  scanf("%d %d", &N, &M);
  mat = new node*[N + 10];
  str = new char*[N + 10];
  for (int i = 0; i < N + 10; i++) {
    mat[i] = new node[M + 10];
    str[i] = new char[M + 10];
  }
  for (int i = 0; i < N + 4; i++) {
    for (int j = 0; j < M + 4; j++) {
      str[i][j] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    scanf("%s", str[i]);
  }
  int res = 0;
  int cnt = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if ('.' == str[i][j]) continue;
      init();
      node* cur = &mat[i][j];
      int tmp = 0;
      while (cur->dir != 0) {
        tmp++;
        switch (cur->dir) {
          case 'U': {
            cur = cur->U;
            DEL(cur->D);
            break;
          }
          case 'D': {
            cur = cur->D;
            DEL(cur->U);
            break;
          }
          case 'R': {
            cur = cur->R;
            DEL(cur->L);
            break;
          }
          case 'L': {
            cur = cur->L;
            DEL(cur->R);
            break;
          }
        }
      }
      if (res < tmp) {
        res = tmp;
        cnt = 1;
      } else if (res == tmp) {
        cnt++;
      }
    }
  }
  printf("%d %d\n", res, cnt);
  return 0;
}
