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[1005][1005];
struct node {
  int i, j;
  node *u, *d, *l, *r;
};
node mm2[1005][1005];
void del(int i, int j) {
  node *sp;
  if (mm2[i][j].l != NULL) {
    sp = mm2[i][j].l;
    sp->r = mm2[i][j].r;
  }
  if (mm2[i][j].r != NULL) {
    sp = mm2[i][j].r;
    sp->l = mm2[i][j].l;
  }
  if (mm2[i][j].u != NULL) {
    sp = mm2[i][j].u;
    sp->d = mm2[i][j].d;
  }
  if (mm2[i][j].d != NULL) {
    sp = mm2[i][j].d;
    sp->u = mm2[i][j].u;
  }
}
void makegraph(int n, int m) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      mm2[i][j].i = i;
      mm2[i][j].j = j;
      if (j > 0)
        mm2[i][j].l = &mm2[i][j - 1];
      else
        mm2[i][j].l = NULL;
      if (j < m - 1)
        mm2[i][j].r = &mm2[i][j + 1];
      else
        mm2[i][j].r = NULL;
      if (i > 0)
        mm2[i][j].u = &mm2[i - 1][j];
      else
        mm2[i][j].u = NULL;
      if (i < n - 1)
        mm2[i][j].d = &mm2[i + 1][j];
      else
        mm2[i][j].d = NULL;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == '.') del(i, j);
    }
  }
}
int cnt, ans, xx;
void work(int i, int j) {
  del(i, j);
  if (mm[i][j] == 'U') {
    if (mm2[i][j].u == NULL)
      return;
    else {
      cnt++;
      work(mm2[i][j].u->i, mm2[i][j].u->j);
    }
  }
  if (mm[i][j] == 'D') {
    if (mm2[i][j].d == NULL)
      return;
    else {
      cnt++;
      work(mm2[i][j].d->i, mm2[i][j].d->j);
    }
  }
  if (mm[i][j] == 'L') {
    if (mm2[i][j].l == NULL)
      return;
    else {
      cnt++;
      work(mm2[i][j].l->i, mm2[i][j].l->j);
    }
  }
  if (mm[i][j] == 'R') {
    if (mm2[i][j].r == NULL)
      return;
    else {
      cnt++;
      work(mm2[i][j].r->i, mm2[i][j].r->j);
    }
  }
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) scanf("%s", &mm[i]);
    ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mm[i][j] == '.') continue;
        makegraph(n, m);
        cnt = 0;
        work(i, j);
        if (cnt > ans) {
          ans = cnt;
          xx = 0;
        }
        if (cnt == ans) xx++;
      }
    }
    printf("%d %d\n", ans + 1, xx);
  }
}
