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;
enum { UP, DOWN, LEFT, RIGHT };
const int MAX = 15500;
struct Node {
  int dir;
  Node* pt[4];
} node[MAX], *cur, *row[MAX], *col[MAX], *st[MAX];
char s[MAX];
int r, c, top;
int getDir(char c) {
  switch (c) {
    case 'U':
      return UP;
    case 'D':
      return DOWN;
    case 'L':
      return LEFT;
    case 'R':
      return RIGHT;
  }
  return -1;
}
void init() {
  cur = node;
  top = 0;
  for (int i = 0; i < r; i++) {
    row[i] = cur++;
    row[i]->pt[LEFT] = row[i]->pt[RIGHT] = row[i];
    row[i]->pt[UP] = row[i]->pt[DOWN] = NULL;
    row[i]->dir = -1;
  }
  for (int i = 0; i < c; i++) {
    col[i] = cur++;
    col[i]->pt[UP] = col[i]->pt[DOWN] = col[i];
    col[i]->pt[LEFT] = col[i]->pt[RIGHT] = NULL;
    col[i]->dir = -1;
  }
}
Node* add(int x, int y, int dir) {
  cur->pt[RIGHT] = row[x]->pt[RIGHT];
  cur->pt[LEFT] = row[x];
  cur->pt[DOWN] = col[y]->pt[DOWN];
  cur->pt[UP] = col[y];
  cur->pt[LEFT]->pt[RIGHT] = cur;
  cur->pt[RIGHT]->pt[LEFT] = cur;
  cur->pt[UP]->pt[DOWN] = cur;
  cur->pt[DOWN]->pt[UP] = cur;
  cur->dir = dir;
  return cur++;
}
int dfs(Node* t) {
  if (t->dir == -1) return 0;
  t->pt[LEFT]->pt[RIGHT] = t->pt[RIGHT];
  t->pt[RIGHT]->pt[LEFT] = t->pt[LEFT];
  t->pt[UP]->pt[DOWN] = t->pt[DOWN];
  t->pt[DOWN]->pt[UP] = t->pt[UP];
  int ret = dfs(t->pt[t->dir]) + 1;
  t->pt[LEFT]->pt[RIGHT] = t;
  t->pt[RIGHT]->pt[LEFT] = t;
  t->pt[UP]->pt[DOWN] = t;
  t->pt[DOWN]->pt[UP] = t;
  return ret;
}
int main() {
  int ret, cnt;
  while (scanf("%d%d", &r, &c) == 2) {
    ret = -1;
    cnt = 0;
    init();
    for (int i = 0; i < r; i++) {
      scanf("%s", &s[i * c]);
    }
    for (int i = r - 1; i >= 0; i--) {
      for (int j = c - 1; j >= 0; j--) {
        if (s[i * c + j] != '.') st[top++] = add(i, j, getDir(s[i * c + j]));
      }
    }
    for (int i = 0; i < top; i++) {
      int sub = dfs(st[i]);
      if (sub > ret) {
        ret = sub;
        cnt = 1;
      } else if (sub == ret) {
        cnt++;
      }
    }
    printf("%d %d\n", ret, cnt);
  }
  return 0;
}
