#include <bits/stdc++.h>
using namespace std;
char mm[5005];
struct node {
  int i, j;
  node *u, *d, *l, *r;
};
node mm2[5005];
void del(int i, int j, int m) {
  node *sp;
  if (mm2[i * m + j].l != NULL) {
    sp = mm2[i * m + j].l;
    sp->r = mm2[i * m + j].r;
  }
  if (mm2[i * m + j].r != NULL) {
    sp = mm2[i * m + j].r;
    sp->l = mm2[i * m + j].l;
  }
  if (mm2[i * m + j].u != NULL) {
    sp = mm2[i * m + j].u;
    sp->d = mm2[i * m + j].d;
  }
  if (mm2[i * m + j].d != NULL) {
    sp = mm2[i * m + j].d;
    sp->u = mm2[i * m + j].u;
  }
}
void makegraph(int n, int m) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      mm2[i * m + j].i = i;
      mm2[i * m + j].j = j;
      if (j > 0)
        mm2[i * m + j].l = &mm2[i * m + j - 1];
      else
        mm2[i * m + j].l = NULL;
      if (j < m - 1)
        mm2[i * m + j].r = &mm2[i * m + j + 1];
      else
        mm2[i * m + j].r = NULL;
      if (i > 0)
        mm2[i * m + j].u = &mm2[(i - 1) * m + j];
      else
        mm2[i * m + j].u = NULL;
      if (i < n - 1)
        mm2[i * m + j].d = &mm2[(i + 1) * m + j];
      else
        mm2[i * m + j].d = NULL;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i * m + j] == '.') del(i, j, m);
    }
  }
}
int cnt, ans, xx;
void work(int i, int j, int m) {
  del(i, j, m);
  if (mm[i * m + j] == 'U') {
    if (mm2[i * m + j].u == NULL)
      return;
    else {
      cnt++;
      work(mm2[i * m + j].u->i, mm2[i * m + j].u->j, m);
    }
  }
  if (mm[i * m + j] == 'D') {
    if (mm2[i * m + j].d == NULL)
      return;
    else {
      cnt++;
      work(mm2[i * m + j].d->i, mm2[i * m + j].d->j, m);
    }
  }
  if (mm[i * m + j] == 'L') {
    if (mm2[i * m + j].l == NULL)
      return;
    else {
      cnt++;
      work(mm2[i * m + j].l->i, mm2[i * m + j].l->j, m);
    }
  }
  if (mm[i * m + j] == 'R') {
    if (mm2[i * m + j].r == NULL)
      return;
    else {
      cnt++;
      work(mm2[i * m + j].r->i, mm2[i * m + j].r->j, m);
    }
  }
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) scanf("%s", &mm[i * m]);
    ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mm[i * m + j] == '.') continue;
        makegraph(n, m);
        cnt = 0;
        work(i, j, m);
        if (cnt > ans) {
          ans = cnt;
          xx = 0;
        }
        if (cnt == ans) xx++;
      }
    }
    printf("%d %d\n", ans + 1, xx);
  }
}
