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 ni() {
  int a;
  scanf("%d", &a);
  return a;
}
double nf() {
  double a;
  scanf("%lf", &a);
  return a;
}
char sbuf[100005];
string ns() {
  scanf("%s", sbuf);
  return sbuf;
}
long long nll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
template <class T>
void out(T a, T b) {
  bool first = true;
  for (T i = a; i != b; ++i) {
    if (!first) printf(" ");
    first = false;
    cout << *i;
  }
  printf("\n");
}
template <class T>
void outl(T a, T b) {
  for (T i = a; i != b; ++i) {
    cout << *i << "\n";
  }
}
int n, m;
vector<string> f;
int ans = -1, ansn;
short nx[5001][5001][5];
int doIt(int y, int x) {
  int dir = -1;
  if (f[y][x] == 'U')
    dir = 0;
  else if (f[y][x] == 'D')
    dir = 1;
  else if (f[y][x] == 'L')
    dir = 2;
  else if (f[y][x] == 'R')
    dir = 3;
  else
    assert(false);
  int xx = x, yy = y;
  while (true) {
    xx = x, yy = y;
    if (dir < 2)
      yy = nx[y][x][dir];
    else
      xx = nx[y][x][dir];
    if (xx == -1 || yy == -1) return 1;
    if (nx[yy][xx][4]) {
      nx[y][x][dir] = nx[yy][xx][dir];
      continue;
    }
    nx[y][x][4] = 1;
    break;
  }
  return doIt(yy, xx) + 1;
}
int main() {
  int i, j, k;
  n = ni();
  m = ni();
  for (i = (0); i < (((n))); ++i) f.push_back(ns());
  int ii, jj;
  for (ii = (0); ii < ((n)); ++ii)
    for (jj = (0); jj < ((m)); ++jj)
      if (f[ii][jj] != '.') {
        for (i = (0); i < (((n))); ++i)
          for (j = (0); j < (((m))); ++j) nx[i][j][4] = 0;
        for (i = (0); i < (((n))); ++i) {
          int ls = -1;
          for (j = (0); j < (((m))); ++j) {
            nx[i][j][2] = ls;
            if (f[i][j] != '.') ls = j;
          }
          ls = -1;
          for (j = m - 1; j >= 0; --j) {
            nx[i][j][3] = ls;
            if (f[i][j] != '.') ls = j;
          }
        }
        for (j = (0); j < (((m))); ++j) {
          int ls = -1;
          for (i = (0); i < (((n))); ++i) {
            nx[i][j][0] = ls;
            if (f[i][j] != '.') ls = i;
          }
          ls = -1;
          for (i = n - 1; i >= 0; --i) {
            nx[i][j][1] = ls;
            if (f[i][j] != '.') ls = i;
          }
        }
        int cur = doIt(ii, jj);
        if (cur > ans) {
          ans = cur;
          ansn = 1;
        } else if (cur == ans)
          ++ansn;
      }
  printf("%d %d\n", ans, ansn);
  return 0;
}
