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>
int vis[5005], R, C, around[5005], CNT[5005];
char maze[5005];
bool out(int x, int y) {
  if (x < 0 || y < 0 || x >= R || y >= C) return 1;
  return 0;
}
void Around(int nx, int ny, int newx, int newy) {
  if (newx == nx - 1 && newy == ny) around[nx * C + ny] = newx * C + newy;
  if (newx == nx + 1 && newy == ny) around[nx * C + ny] = newx * C + newy;
  if (newx == nx && newy == ny - 1) around[nx * C + ny] = newx * C + newy;
  if (newx == nx && newy == ny + 1) around[nx * C + ny] = newx * C + newy;
}
void find_path(int nx, int ny, int x, int y, int cnt, int& Max) {
  if (out(x, y)) return;
  if (cnt > Max) Max = cnt;
  CNT[x * C + y] = cnt;
  vis[x * C + y] = 1;
  if (maze[x * C + y] == 'U') {
    int newx = x - 1, newy = y;
    while (maze[newx * C + newy] == '.' || vis[newx * C + newy]) {
      newx = newx - 1;
      if (out(newx, newy)) break;
    }
    Around(nx, ny, newx, newy);
    find_path(nx, ny, newx, newy, cnt + 1, Max);
  } else if (maze[x * C + y] == 'D') {
    int newx = x + 1, newy = y;
    while (maze[newx * C + newy] == '.' || vis[newx * C + newy]) {
      newx = newx + 1;
      if (out(newx, newy)) break;
    }
    Around(nx, ny, newx, newy);
    find_path(nx, ny, newx, newy, cnt + 1, Max);
  } else if (maze[x * C + y] == 'L') {
    int newx = x, newy = y - 1;
    while (maze[newx * C + newy] == '.' || vis[newx * C + newy]) {
      newy = newy - 1;
      if (out(newx, newy)) break;
    }
    Around(nx, ny, newx, newy);
    find_path(nx, ny, newx, newy, cnt + 1, Max);
  } else if (maze[x * C + y] == 'R') {
    int newx = x, newy = y + 1;
    while (maze[newx * C + newy] == '.' || vis[newx * C + newy]) {
      newy = newy + 1;
      if (out(newx, newy)) break;
    }
    Around(nx, ny, newx, newy);
    find_path(nx, ny, newx, newy, cnt + 1, Max);
  }
}
int main() {
  while (~scanf("%d%d", &R, &C)) {
    getchar();
    memset(maze, 0, sizeof maze);
    memset(CNT, 0, sizeof CNT);
    for (int i = 0; i < R; i++) {
      for (int j = 0; j < C; j++) scanf("%c", &maze[i * C + j]);
      getchar();
    }
    int ans = 0, cnt = 0, cur = 0;
    for (int i = 0; i < R; i++)
      for (int j = 0; j < C; j++) {
        if (maze[i * C + j] == '.') continue;
        memset(vis, 0, sizeof vis);
        int flag = 0;
        if (maze[i * C + j] == 'U' && around[(i - 1) * C + j] == i * C + j)
          cur = CNT[(i - 1) * C + j] + 1, flag = 1;
        else if (maze[i * C + j] == 'D' && around[(i + 1) * C + j] == i * C + j)
          cur = CNT[(i + 1) * C + j] + 1, flag = 1;
        else if (maze[i * C + j] == 'R' && around[i * C + j + 1] == i * C + j)
          cur = CNT[i * C + j + 1] + 1, flag = 1;
        else if (maze[i * C + j] == 'L' && around[i * C + j - 1] == i * C + j)
          cur = CNT[i * C + j - 1] + 1, flag = 1;
        else
          find_path(i, j, i, j, 0, cur = 0);
        if (cur > ans)
          ans = cur, cnt = 1;
        else if (cur == ans)
          cnt++;
      }
    printf("%d %d\n", ans + 1, cnt);
  }
  return 0;
}
