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;
struct node {
  int l, r, u, d, x, y;
  void init() { l = r = u = d = x = y = 0; }
};
node tmp[5010], p[5010];
vector<char> G[5010], a[5010];
vector<int> pos[5010];
int n, m, size;
int ans, sum, cnt;
int left(int x, int y) {
  for (int i = y - 1; i >= 0; i--) {
    if (G[x][i] != '.') return pos[x][i];
  }
  return -1;
}
int right(int x, int y) {
  for (int i = y + 1; i < m; i++) {
    if (G[x][i] != '.') return pos[x][i];
  }
  return -1;
}
int up(int x, int y) {
  for (int i = x - 1; i >= 0; i--) {
    if (G[i][y] != '.') return pos[i][y];
  }
  return -1;
}
int down(int x, int y) {
  for (int i = x + 1; i < n; i++) {
    if (G[i][y] != '.') return pos[i][y];
  }
  return -1;
}
void Delete(int id) {
  tmp[tmp[id].l].r = tmp[id].r;
  tmp[tmp[id].r].l = tmp[id].l;
  tmp[tmp[id].u].d = tmp[id].d;
  tmp[tmp[id].d].u = tmp[id].u;
}
void gao(int x, int y) {
  int i, j, id;
  for (i = 1; i <= size; i++) tmp[i] = p[i];
  id = pos[x][y];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) G[i][j] = a[i][j];
  }
  while (id != -1) {
    sum++;
    x = tmp[id].x;
    y = tmp[id].y;
    Delete(id);
    if (G[x][y] == 'L')
      id = tmp[id].l;
    else if (G[x][y] == 'R')
      id = tmp[id].r;
    else if (G[x][y] == 'U')
      id = tmp[id].u;
    else if (G[x][y] == 'D')
      id = tmp[id].d;
    else
      break;
    G[x][y] = '.';
  }
}
int main() {
  int i, j;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 0; i < n; i++) {
      G[i].clear();
      G[i].resize(m);
      pos[i].clear();
      pos[i].resize(m);
      a[i].clear();
      a[i].resize(m);
    }
    size = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        scanf(" %c", &G[i][j]);
        a[i][j] = G[i][j];
        if (a[i][j] != '.') {
          pos[i][j] = ++size;
          p[size].x = i;
          p[size].y = j;
        } else
          pos[i][j] = 0;
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == '.') continue;
        p[pos[i][j]].l = left(i, j);
        p[pos[i][j]].r = right(i, j);
        p[pos[i][j]].u = up(i, j);
        p[pos[i][j]].d = down(i, j);
      }
    }
    ans = cnt = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == '.') continue;
        sum = 0;
        gao(i, j);
        if (sum > ans) {
          ans = sum;
          cnt = 1;
        } else if (sum == ans)
          cnt++;
      }
    }
    printf("%d %d\n", ans, cnt);
  }
  return 0;
}
