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** mat;
short ***sparse, ***rem;
void build() {
  sparse = new short**[n + 1];
  rem = new short**[n + 1];
  for (int i = 0; i <= n; ++i) {
    sparse[i] = new short*[m + 1];
    rem[i] = new short*[m + 1];
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      sparse[i][j] = new short[4];
      memset(sparse[i][j], 0, sizeof(short) * 4);
      rem[i][j] = new short[4];
      memset(rem[i][j], 0, sizeof(short) * 4);
    }
  }
  for (int i = 1; i <= n; ++i) {
    int prev = 0;
    for (int j = 1; j <= m; ++j) {
      if (mat[i][j]) {
        sparse[i][j][0] = prev;
        prev = j;
      }
    }
    prev = 0;
    for (int j = m; j > 0; --j) {
      if (mat[i][j]) {
        sparse[i][j][1] = prev;
        prev = j;
      }
    }
  }
  for (int j = 1; j <= m; ++j) {
    int prev = 0;
    for (int i = 1; i <= n; ++i) {
      if (mat[i][j]) {
        sparse[i][j][2] = prev;
        prev = i;
      }
    }
    prev = 0;
    for (int i = n; i > 0; --i) {
      if (mat[i][j]) {
        sparse[i][j][3] = prev;
        prev = i;
      }
    }
  }
}
void remove(int p, int q) {
  int prox, prev;
  prox = sparse[p][q][0];
  prev = sparse[p][q][1];
  if (prev) sparse[p][prev][0] = prox;
  if (prox) sparse[p][prox][1] = prev;
  rem[p][q][0] = prox;
  prox = sparse[p][q][1];
  prev = sparse[p][q][0];
  if (prev) sparse[p][prev][1] = prox;
  if (prox) sparse[p][prox][0] = prev;
  rem[p][q][1] = prox;
  prox = sparse[p][q][2];
  prev = sparse[p][q][3];
  if (prev) sparse[prev][q][2] = prox;
  if (prox) sparse[prox][q][3] = prev;
  rem[p][q][2] = prox;
  prox = sparse[p][q][3];
  prev = sparse[p][q][2];
  if (prev) sparse[prev][q][3] = prox;
  if (prox) sparse[prox][q][2] = prev;
  rem[p][q][3] = prox;
}
void insert(int p, int q) {
  int x;
  x = rem[p][q][0];
  if (x) sparse[p][x][1] = q;
  x = rem[p][q][1];
  if (x) sparse[p][x][0] = q;
  x = rem[p][q][2];
  if (x) sparse[x][q][3] = p;
  x = rem[p][q][3];
  if (x) sparse[x][q][2] = p;
  for (int i = 0; i < 4; ++i) rem[p][q][i] = 0;
}
int solve(int p, int q) {
  int tot = 0;
  stack<pair<int, int> > s;
  while (p and q) {
    int prox, prev;
    if (mat[p][q] == 'L') {
      prox = sparse[p][q][0];
      if (p and q) remove(p, q);
      if (p and q) s.push(make_pair(p, q));
      q = prox;
    } else if (mat[p][q] == 'R') {
      prox = sparse[p][q][1];
      if (p and q) remove(p, q);
      if (p and q) s.push(make_pair(p, q));
      q = prox;
    } else if (mat[p][q] == 'U') {
      prox = sparse[p][q][2];
      if (p and q) remove(p, q);
      if (p and q) s.push(make_pair(p, q));
      p = prox;
    } else {
      prox = sparse[p][q][3];
      if (p and q) remove(p, q);
      if (p and q) s.push(make_pair(p, q));
      p = prox;
    }
    tot++;
  }
  while (s.size()) {
    pair<int, int> p = s.top();
    s.pop();
    insert(p.first, p.second);
  }
  return tot;
}
int main(int argc, char* argv[]) {
  cin >> n >> m;
  mat = new char*[n + 1];
  for (int i = 0; i <= n; ++i) mat[i] = new char[m + 1];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> mat[i][j];
      if (mat[i][j] == '.') mat[i][j] = 0;
    }
  }
  build();
  int ans = 0, freq = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int x = mat[i][j] ? solve(i, j) : 0;
      if (x > ans) {
        ans = x;
        freq = 1;
      } else if (x == ans)
        freq++;
    }
  }
  cout << ans << " " << freq << endl;
  return 0;
}
