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 MOD = 1e9 + 7;
long long M = 550;
long long n, k, t0, m;
vector<string> a;
int maxV = 0;
int maxVCount = 0;
vector<vector<vector<int>>> ma;
int getMa(int t, int r, int c) {
  if (r == -1 || c == -1) return -1;
  return ma[t][r][c];
}
void setMa(int t, int r, int c, int v) {
  if (r == -1 || c == -1) return;
  ma[t][r][c] = v;
}
bool search(int r, int c, int v) {
  v++;
  if (v > maxV) {
    maxV = v;
    maxVCount = 1;
  } else if (v == maxV) {
    maxVCount++;
  }
  int temp[5];
  temp[0] = getMa(0, ma[2][r][c], c);
  temp[1] = getMa(1, r, ma[3][r][c]);
  temp[2] = getMa(2, ma[0][r][c], c);
  temp[3] = getMa(3, r, ma[1][r][c]);
  setMa(0, ma[2][r][c], c, ma[0][r][c]);
  setMa(1, r, ma[3][r][c], ma[1][r][c]);
  setMa(2, ma[0][r][c], c, ma[2][r][c]);
  setMa(3, r, ma[1][r][c], ma[3][r][c]);
  if (a[r][c] == 'U') {
    if (ma[0][r][c] != -1) {
      search(ma[0][r][c], c, v);
    }
  } else if (a[r][c] == 'R') {
    if (ma[1][r][c] != -1) {
      search(r, ma[1][r][c], v);
    }
  } else if (a[r][c] == 'D') {
    if (ma[2][r][c] != -1) {
      search(ma[2][r][c], c, v);
    }
  } else if (a[r][c] == 'L') {
    if (ma[3][r][c] != -1) {
      search(r, ma[3][r][c], v);
    }
  }
  setMa(0, ma[2][r][c], c, temp[0]);
  setMa(1, r, ma[3][r][c], temp[1]);
  setMa(2, ma[0][r][c], c, temp[2]);
  setMa(3, r, ma[1][r][c], temp[3]);
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  ma = vector<vector<vector<int>>>(
      4, vector<vector<int>>(n + 10, vector<int>(m + 10, -1)));
  a = vector<string>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> last = vector<int>(m + 10, -1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != '.') {
        ma[0][i][j] = last[j];
        last[j] = i;
      }
    }
  }
  last = vector<int>(n + 10, -1);
  for (int j = m - 1; j >= 0; j--) {
    for (int i = 0; i < n; i++) {
      if (a[i][j] != '.') {
        ma[1][i][j] = last[i];
        last[i] = j;
      }
    }
  }
  last = vector<int>(m + 10, -1);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != '.') {
        ma[2][i][j] = last[j];
        last[j] = i;
      }
    }
  }
  last = vector<int>(n + 10, -1);
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      if (a[i][j] != '.') {
        ma[3][i][j] = last[i];
        last[i] = j;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != '.') {
        search(i, j, 0);
      }
    }
  }
  printf("%d %d", maxV, maxVCount);
}
