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;
long long labs(long long a) { return a < 0 ? (-a) : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
template <typename T>
struct Point {
  T x, y;
  Point() {}
  Point(T xx, T yy) : x(xx), y(yy) {}
};
template <typename T>
bool operator<(const Point<T> &p1, const Point<T> &p2) {
  return p1.x < p2.x || p1.x == p2.x && p1.y < p2.y;
}
vector<vector<short> > mas, lm, rm, um, dm;
vector<vector<short> > mas0, lm0, rm0, um0, dm0;
vector<vector<vector<short> > *> v, v0;
short n, m;
const short LEFT = 1, RIGHT = 2, UP = 3, DOWN = 4, EMPTY = 0;
void CalcRight() {
  for (int(i) = 0; (i) < (n); (i)++) {
    short last = m;
    for (int(j) = (m)-1; (j) >= 0; (j)--) {
      rm0[i][j] = last;
      if (mas0[i][j] != EMPTY) last = j;
    }
  }
}
void CalcDown() {
  for (int(j) = 0; (j) < (m); (j)++) {
    short last = n;
    for (int(i) = (n)-1; (i) >= 0; (i)--) {
      dm0[i][j] = last;
      if (mas0[i][j] != EMPTY) last = i;
    }
  }
}
void CalcUp() {
  for (int(j) = 0; (j) < (m); (j)++) {
    short last = -1;
    for (int(i) = 0; (i) < (n); (i)++) {
      um0[i][j] = last;
      if (mas0[i][j] != EMPTY) last = i;
    }
  }
}
void CalcLeft() {
  for (int(i) = 0; (i) < (n); (i)++) {
    short last = -1;
    for (int(j) = 0; (j) < (m); (j)++) {
      lm0[i][j] = last;
      if (mas0[i][j] != EMPTY) last = j;
    }
  }
}
void Calc() {
  CalcLeft();
  CalcRight();
  CalcUp();
  CalcDown();
}
void Copy() {
  for (int(i) = 0; (i) < (v.size()); (i)++) {
    (*v[i]) = (*v0[i]);
  }
}
bool IsInBorder(short i, short j) { return i >= 0 && j >= 0 && i < n && j < m; }
short Go(short i, short j, short mode) {
  if (mode == LEFT || mode == RIGHT) {
    if (!IsInBorder(i, j) || mas[i][j] != EMPTY) return j;
    (*v[mode])[i][j] = Go(i, (*v[mode])[i][j], mode);
    return (*v[mode])[i][j];
  } else {
    if (!IsInBorder(i, j) || mas[i][j] != EMPTY) return i;
    (*v[mode])[i][j] = Go((*v[mode])[i][j], j, mode);
    return (*v[mode])[i][j];
  }
}
int main() {
  cin >> n >> m;
  v.push_back(&mas);
  v.push_back(&lm);
  v.push_back(&rm);
  v.push_back(&um);
  v.push_back(&dm);
  v0.push_back(&mas0);
  v0.push_back(&lm0);
  v0.push_back(&rm0);
  v0.push_back(&um0);
  v0.push_back(&dm0);
  for (int(i) = 0; (i) < (v0.size()); (i)++) {
    v0[i]->resize(n, vector<short>(m));
  }
  char c;
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      cin >> c;
      switch (c) {
        case 'L':
          mas0[i][j] = LEFT;
          break;
        case 'R':
          mas0[i][j] = RIGHT;
          break;
        case 'U':
          mas0[i][j] = UP;
          break;
        case 'D':
          mas0[i][j] = DOWN;
          break;
        default:
          mas0[i][j] = EMPTY;
      }
    }
  }
  Calc();
  short bestl = 0;
  short bestcnt = 0;
  short a, b, l, mode;
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      if (mas0[i][j] == EMPTY) continue;
      Copy();
      a = i;
      b = j;
      l = 0;
      while (IsInBorder(a, b)) {
        l++;
        mode = mas[a][b];
        mas[a][b] = EMPTY;
        if (mode == LEFT || mode == RIGHT) {
          b = Go(a, b, mode);
        } else {
          a = Go(a, b, mode);
        }
      }
      if (l > bestl) {
        bestl = l;
        bestcnt = 1;
      } else if (l == bestl) {
        bestcnt++;
      }
    }
  }
  cout << bestl << " " << bestcnt;
  return 0;
}
