10 10
.L.....R..
.........U
..D....D..
.R......L.
....L.....
.........D
......U...
D....R....
...U......
........L.
 5 5
DD..D
.....
LU...
U...U
.UL.U
 1 1
U
 5 5
UD..L
RRD..
..RDD
UUL..
DDLRR
 19 23
U..U..R........L...D...
.D.....UL.U.U........DR
..D.U..D....L......R...
D.......RL.L....D.....R
U..D.....U...U.L..D...U
...........L...........
U....U....D.U......LRR.
......RL...U...L.......
DLU..U......UU.U.U.D...
...........D....U......
U...DL......LL.....R...
...U..DD..........LD...
.R.........D.....UU...U
....D......R..........D
.L..........R.....L....
.R........L.LL....R....
..R...D........R....D..
.LR.R..LDU.DDRL......U.
...LL.....D.....DD.....
 11 29
URRUUDDLURLRDDLLRLDUDR.UDLLD.
LRRUDLUDLDULUDL.DURDRR.RRLLRR
D.DUDDURLRDDULDUDDUDDURRDLD.L
.RULURURRDLRRRLUUUU.RDLDLRRRL
.RLDDU.UUULUURURRLLUU.RLDRDUD
LRL.URRRDDURUURUDRRDLDDULRDRL
RLULDU.LRDUDRLDLRDDDDRUUDRDLL
DLUDURRDDUDLLDLLUURLDRUURRLUL
L.RRURRDDRRURRRDDUDRRDULR.LUR
LDLRULURRUULRDUUULLU.LLU.LLLL
DUURDULDDUDLRUUDRUULURLD.RL.U
 2 2
RD
UL
 1 10
LLLLLRRRRR
 3 3
...
...
..R
 17 13
...LD.UR.RUU.
LDLULDUDRRDRL
DD.RRLRUR.UD.
RU...D...LD..
.UR.R...URUUD
.RURD.RLR.D.R
.UUU.RU...UR.
UUUU.R.......
RL.LRU.UD.DUD
LD.DRURRLRDRL
.DR..UULUDDR.
LRLURRUUDDLUR
.LRDDLLR.L.DU
DRUDLLD.LRRU.
..DL.UDL.DUL.
U.DL..D..U.RD
RR.R...RL.L..

2 2
 4 1
 1 1
 8 3
 9 1
 94 1
 4 4
 5 2
 1 1
 24 2

#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);
  }
}
