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>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
string s[5000];
vector<int> t[5000];
string ss[5000];
vector<pair<int, int> > root[4][5000];
vector<pair<int, int> > next239[4][5000];
int good(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }
int ans[10000];
pair<int, int> get_root(int t, pair<int, int> o) {
  if (root[t][o.first][o.second] == o) return o;
  return root[t][o.first][o.second] = get_root(t, root[t][o.first][o.second]);
}
void merge(int t, pair<int, int> a, pair<int, int> b) {
  a = get_root(t, a);
  root[t][a.first][a.second] = get_root(t, b);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (n); i++) cin >> s[i];
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++)
      if (s[i][j] != '.') {
        int c = s[i][j];
        if (c == 'U') t[i].push_back(3);
        if (c == 'D') t[i].push_back(1);
        if (c == 'L') t[i].push_back(2);
        if (c == 'R') t[i].push_back(0);
      } else
        t[i].push_back(-1);
  for (int o = 0; o < (4); o++) {
    for (int i = 0; i < (n); i++)
      for (int j = 0; j < (m); j++) {
        int cx = i + dx[o];
        int cy = j + dy[o];
        while (good(cx, cy) && s[cx][cy] == '.') {
          cx += dx[o];
          cy += dy[o];
        }
        if (good(cx, cy))
          next239[o][i].push_back(make_pair(cx, cy));
        else
          next239[o][i].push_back(make_pair(n, m));
      }
  }
  for (int o = 0; o < (4); o++)
    for (int i = 0; i < (n + 1); i++) root[o][i].resize(m + 1);
  for (int x = 0; x < (n); x++)
    for (int y = 0; y < (m); y++)
      if (s[x][y] != '.') {
        for (int i = 0; i < (n + 1); i++)
          for (int j = 0; j < (m + 1); j++)
            for (int o = 0; o < (4); o++) root[o][i][j] = make_pair(i, j);
        int cx = x, cy = y;
        int col = 1;
        while (good(cx, cy)) {
          pair<int, int> tmp = get_root(t[cx][cy], next239[t[cx][cy]][cx][cy]);
          if (!good(tmp.first, tmp.second)) break;
          for (int o = 0; o < (4); o++) {
            merge(o, make_pair(cx, cy), next239[o][cx][cy]);
          }
          cx = tmp.first;
          cy = tmp.second;
          col++;
        }
        ans[col]++;
      }
  int o = n * m;
  while (ans[o] == 0) o--;
  cout << o << ' ' << ans[o] << endl;
  return 0;
}
