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;
void solve();
int main() {
  int t = 1;
  while (t--) solve();
}
int n, m;
set<int> str[6000], stolb[6000], str1[6000], stolb1[6000];
string matrix[6000];
bool used[6000][6000];
void clear(int i, int j) {
  used[i][j] = true;
  str[i].erase(j);
  str1[i].erase(-j);
  stolb[j].erase(i);
  stolb1[j].erase(-i);
}
int dfs1(pair<int, int> cur) {
  used[cur.first][cur.second];
  char c = matrix[cur.first][cur.second];
  if (c == 'U') {
    if (((stolb1[cur.second].lower_bound(-cur.first))) !=
        (stolb1[cur.second].end())) {
      int now = *(stolb1[cur.second].lower_bound(-cur.first));
      now = -now;
      pair<int, int> today = make_pair(now, cur.second);
      clear(today.first, today.second);
      return dfs1(today) + 1;
    } else
      return 0;
  }
  if (c == 'D') {
    if (((stolb[cur.second].lower_bound(cur.first))) !=
        (stolb[cur.second].end())) {
      int now = *(stolb[cur.second].lower_bound(-cur.first));
      pair<int, int> today = make_pair(now, cur.second);
      clear(today.first, today.second);
      return dfs1(today) + 1;
    } else
      return 0;
  }
  if (c == 'L') {
    if (((str1[cur.first].lower_bound(-cur.second))) !=
        (str1[cur.first].end())) {
      int now = *(str1[cur.first].lower_bound(-cur.second));
      now = -now;
      pair<int, int> today = make_pair(cur.first, now);
      clear(today.first, today.second);
      return dfs1(today) + 1;
    } else
      return 0;
  }
  if (c == 'R') {
    if (((str[cur.first].lower_bound(cur.second))) != (str[cur.first].end())) {
      int now = *(str[cur.first].lower_bound(cur.second));
      pair<int, int> today = make_pair(cur.first, now);
      clear(today.first, today.second);
      return dfs1(today) + 1;
    } else
      return 0;
  }
}
int dfs2(pair<int, int> cur) {
  char c = matrix[cur.first][cur.second];
  if (c == 'D') {
    if (((stolb1[cur.second].lower_bound(-cur.first))) !=
        (stolb1[cur.second].end())) {
      int now = *(stolb1[cur.second].lower_bound(-cur.first));
      now = -now;
      pair<int, int> today = make_pair(now, cur.second);
      clear(today.first, today.second);
      return dfs2(today) + 1;
    } else
      return 0;
  }
  if (c == 'U') {
    if (((stolb[cur.second].lower_bound(cur.first))) !=
        (stolb[cur.second].end())) {
      int now = *(stolb[cur.second].lower_bound(-cur.first));
      pair<int, int> today = make_pair(now, cur.second);
      clear(today.first, today.second);
      return dfs2(today) + 1;
    } else
      return 0;
  }
  if (c == 'R') {
    if (((str1[cur.first].lower_bound(-cur.second))) !=
        (str1[cur.first].end())) {
      int now = *(str1[cur.first].lower_bound(-cur.second));
      now = -now;
      pair<int, int> today = make_pair(cur.first, now);
      clear(today.first, today.second);
      return dfs2(today) + 1;
    } else
      return 0;
  }
  if (c == 'L') {
    if (((str[cur.first].lower_bound(cur.second))) != (str[cur.first].end())) {
      int now = *(str[cur.first].lower_bound(cur.second));
      pair<int, int> today = make_pair(cur.first, now);
      clear(today.first, today.second);
      return dfs2(today) + 1;
    } else
      return 0;
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string q;
    cin >> q;
    matrix[i] = q;
    for (int j = 0; j < q.length(); j++) {
      char c = q[j];
      if (c != '.') {
        str[i].insert(j);
        stolb[j].insert(i);
        str1[i].insert(-j);
        stolb1[j].insert(-i);
      }
    }
  }
  int ans = 0;
  int num = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (matrix[i][j] != '.' && !used[i][j]) {
        char c = matrix[i][j];
        vector<pair<int, int> > need;
        pair<int, int> cur = make_pair(i, j);
        int z = dfs1(make_pair(i, j));
        if (z == ans) num++;
        if (z > ans) {
          num = 1;
          ans = z;
        }
        memset(used, 0, sizeof(used));
        for (int i = 0; i < n; i++) {
          string q = matrix[i];
          for (int j = 0; j < q.length(); j++) {
            char c = q[j];
            if (c != '.') {
              str[i].insert(j);
              stolb[j].insert(i);
              str1[i].insert(-j);
              stolb1[j].insert(-i);
            }
          }
        }
      }
  cout << ans << ' ' << num << endl;
}
