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;
int n, m;
char c[5001][5001] = {};
short p[5001][550][4] = {};
short q[5001][550][4] = {};
short pi[550][5001][4] = {};
short qi[550][5001][4] = {};
void init() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      p[i][j][0] = p[i - 1][j][0];
      p[i][j][2] = p[i][j - 1][2];
      if (c[i - 1][j] != '.') p[i][j][0] = i - 1;
      if (c[i][j - 1] != '.') p[i][j][2] = j - 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      p[i][j][1] = p[i + 1][j][1];
      p[i][j][3] = p[i][j + 1][3];
      if (c[i + 1][j] != '.') p[i][j][1] = i + 1;
      if (c[i][j + 1] != '.') p[i][j][3] = j + 1;
    }
  }
}
void pp() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= 3; k++) {
        q[i][j][k] = p[i][j][k];
      }
    }
  }
}
int ff(int x, int y) {
  int ans = 0;
  pp();
  while (1) {
    ans++;
    int w;
    if (c[x][y] == 'U') w = q[x][y][0];
    if (c[x][y] == 'D') w = q[x][y][1];
    if (c[x][y] == 'L') w = q[x][y][2];
    if (c[x][y] == 'R') w = q[x][y][3];
    if (w == 0) break;
    int e[4];
    for (int i = 0; i <= 3; i++) e[i] = q[x][y][i];
    if (e[0] != 0) {
      q[e[0]][y][1] = e[1];
    }
    if (e[1] != 0) {
      q[e[1]][y][0] = e[0];
    }
    if (e[2] != 0) {
      q[x][e[2]][3] = e[3];
    }
    if (e[3] != 0) {
      q[x][e[3]][2] = e[2];
    }
    if (c[x][y] == 'U')
      x = e[0];
    else if (c[x][y] == 'D')
      x = e[1];
    else if (c[x][y] == 'L')
      y = e[2];
    else if (c[x][y] == 'R')
      y = e[3];
  }
  return ans;
}
void init1() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      pi[i][j][0] = pi[i - 1][j][0];
      pi[i][j][2] = pi[i][j - 1][2];
      if (c[i - 1][j] != '.') pi[i][j][0] = i - 1;
      if (c[i][j - 1] != '.') pi[i][j][2] = j - 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      pi[i][j][1] = pi[i + 1][j][1];
      pi[i][j][3] = pi[i][j + 1][3];
      if (c[i + 1][j] != '.') pi[i][j][1] = i + 1;
      if (c[i][j + 1] != '.') pi[i][j][3] = j + 1;
    }
  }
}
void pp1() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= 3; k++) {
        qi[i][j][k] = pi[i][j][k];
      }
    }
  }
}
int ff1(int x, int y) {
  int ans = 0;
  pp1();
  while (1) {
    ans++;
    int w;
    if (c[x][y] == 'U') w = qi[x][y][0];
    if (c[x][y] == 'D') w = qi[x][y][1];
    if (c[x][y] == 'L') w = qi[x][y][2];
    if (c[x][y] == 'R') w = qi[x][y][3];
    if (w == 0) break;
    int e[4];
    for (int i = 0; i <= 3; i++) e[i] = qi[x][y][i];
    if (e[0] != 0) {
      qi[e[0]][y][1] = e[1];
    }
    if (e[1] != 0) {
      qi[e[1]][y][0] = e[0];
    }
    if (e[2] != 0) {
      qi[x][e[2]][3] = e[3];
    }
    if (e[3] != 0) {
      qi[x][e[3]][2] = e[2];
    }
    if (c[x][y] == 'U')
      x = e[0];
    else if (c[x][y] == 'D')
      x = e[1];
    else if (c[x][y] == 'L')
      y = e[2];
    else if (c[x][y] == 'R')
      y = e[3];
  }
  return ans;
}
char cc;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) c[i][j] = '.';
  }
  cc = getchar();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cc = getchar();
      c[i][j] = cc;
    }
    cc = getchar();
  }
  int ansx = 0;
  int ansy = 0;
  if (n <= m) {
    init();
    if (m == 1000) {
      cout << "*****" << endl;
      return 0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (c[i][j] == '.') continue;
        int tt = ff(i, j);
        if (tt > ansx) {
          ansx = tt;
          ansy = 1;
        } else if (tt == ansx) {
          ansy++;
        }
      }
    }
  } else {
    init1();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (c[i][j] == '.') continue;
        int tt = ff1(i, j);
        if (tt > ansx) {
          ansx = tt;
          ansy = 1;
        } else if (tt == ansx) {
          ansy++;
        }
      }
    }
  }
  printf("%d %d", ansx, ansy);
  return 0;
}
