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;
vector<vector<pair<int, int> > > roww;
vector<vector<pair<int, int> > > colw;
vector<string> board;
int R, C;
int cnt = 0;
void processRow() {
  for (int i = 0; i < R; i++) {
    int priv = -1;
    for (int j = 0; j < C; j++) {
      if (board[i][j] == '.') continue;
      if (priv != -1) {
        roww[i][j].first = priv;
        roww[i][priv].second = j;
        priv = j;
      } else {
        priv = j;
      }
    }
  }
}
void processCol() {
  for (int j = 0; j < C; j++) {
    int priv = -1;
    for (int i = 0; i < R; i++) {
      if (board[i][j] == '.') continue;
      if (priv != -1) {
        colw[i][j].first = priv;
        colw[priv][j].second = i;
        priv = i;
      } else {
        priv = i;
      }
    }
  }
}
void dfs(int r, int c) {
  int tham;
  cnt++;
  if (board[r][c] == 'U') {
    if (colw[r][c].first == -1) return;
    int nxt = colw[r][c].first;
    colw[nxt][c].second = colw[r][c].second;
    if (colw[r][c].second != -1) {
      int priv = colw[r][c].second;
      colw[priv][c].first = nxt;
    }
    if (roww[r][c].first != -1) {
      int baam = roww[r][c].first;
      roww[r][baam].second = roww[r][c].second;
    }
    if (roww[r][c].second != -1) {
      int daan = roww[r][c].second;
      roww[r][daan].first = roww[r][c].first;
    }
    dfs(nxt, c);
    colw[nxt][c].second = r;
    if (colw[r][c].second != -1) {
      int priv = colw[r][c].second;
      colw[priv][c].first = r;
    }
    if (roww[r][c].first != -1) {
      int baam = roww[r][c].first;
      roww[r][baam].second = c;
    }
    if (roww[r][c].second != -1) {
      int daan = roww[r][c].second;
      roww[r][daan].first = c;
    }
  }
  if (board[r][c] == 'D') {
    if (colw[r][c].second == -1) return;
    int nxt = colw[r][c].second;
    colw[nxt][c].first = colw[r][c].first;
    if (colw[r][c].first != -1) {
      int priv = colw[r][c].first;
      colw[priv][c].second = nxt;
    }
    if (roww[r][c].first != -1) {
      int baam = roww[r][c].first;
      roww[r][baam].second = roww[r][c].second;
    }
    if (roww[r][c].second != -1) {
      int daan = roww[r][c].second;
      roww[r][daan].first = roww[r][c].first;
    }
    dfs(nxt, c);
    colw[nxt][c].first = r;
    if (colw[r][c].first != -1) {
      int priv = colw[r][c].first;
      colw[priv][c].second = r;
    }
    if (roww[r][c].first != -1) {
      int baam = roww[r][c].first;
      roww[r][baam].second = c;
    }
    if (roww[r][c].second != -1) {
      int daan = roww[r][c].second;
      roww[r][daan].first = c;
    }
  }
  if (board[r][c] == 'R') {
    if (roww[r][c].second == -1) return;
    int nxt = roww[r][c].second;
    roww[r][nxt].first = roww[r][c].first;
    if (roww[r][c].first != -1) {
      int priv = roww[r][c].first;
      roww[r][priv].second = nxt;
    }
    if (colw[r][c].first != -1) {
      int upor = colw[r][c].first;
      colw[upor][c].second = colw[r][c].second;
    }
    if (colw[r][c].second != -1) {
      int nich = colw[r][c].second;
      colw[nich][c].first = colw[r][c].first;
    }
    dfs(r, nxt);
    roww[r][nxt].first = c;
    if (roww[r][c].first != -1) {
      int priv = roww[r][c].first;
      roww[r][priv].second = c;
    }
    if (colw[r][c].first != -1) {
      int upor = colw[r][c].first;
      colw[upor][c].second = r;
    }
    if (colw[r][c].second != -1) {
      int nich = colw[r][c].second;
      colw[nich][c].first = r;
    }
  }
  if (board[r][c] == 'L') {
    if (roww[r][c].first == -1) return;
    int nxt = roww[r][c].first;
    roww[r][nxt].second = roww[r][c].second;
    if (roww[r][c].second != -1) {
      int priv = roww[r][c].second;
      roww[r][priv].first = nxt;
    }
    if (colw[r][c].first != -1) {
      int upor = colw[r][c].first;
      colw[upor][c].second = colw[r][c].second;
    }
    if (colw[r][c].second != -1) {
      int nich = colw[r][c].second;
      colw[nich][c].first = colw[r][c].first;
    }
    dfs(r, nxt);
    roww[r][nxt].second = c;
    if (roww[r][c].second != -1) {
      int priv = roww[r][c].second;
      roww[r][priv].first = c;
    }
    if (colw[r][c].first != -1) {
      int upor = colw[r][c].first;
      colw[upor][c].second = r;
    }
    if (colw[r][c].second != -1) {
      int nich = colw[r][c].second;
      colw[nich][c].first = r;
    }
  }
}
int main() {
  cin >> R >> C;
  string line = "";
  vector<pair<int, int> > cc;
  pair<int, int> p;
  p.first = -1;
  p.second = -1;
  for (int i = 0; i < C; i++) {
    cc.push_back(p);
  }
  for (int i = 0; i < R; i++) {
    roww.push_back(cc);
    colw.push_back(cc);
  }
  for (int i = 0; i < R; i++) {
    cin >> line;
    board.push_back(line);
  }
  processRow();
  processCol();
  int mx = 0;
  int oc = 0;
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      if (board[i][j] == '.') continue;
      cnt = 0;
      dfs(i, j);
      if (cnt == mx)
        oc++;
      else if (cnt > mx) {
        mx = cnt;
        oc = 1;
      }
    }
  }
  cout << mx << " " << oc << "\n";
  return 0;
}
