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;
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
int d[5001], n, m;
pair<int, int> p[5001][5];
int d1[5001];
pair<int, int> p1[5001][5];
void sP(int x, int y, int k, pair<int, int> a) { p[x * m + y][k] = a; }
pair<int, int> gP(int x, int y, int k) { return p[x * m + y][k]; }
void sD(int x, int y, int a) { d[x * m + y] = a; }
int gD(int x, int y) { return d[x * m + y]; }
void sP1(int x, int y, int k, pair<int, int> a) { p1[x * m + y][k] = a; }
pair<int, int> gP1(int x, int y, int k) { return p1[x * m + y][k]; }
void sD1(int x, int y, int a) { d1[x * m + y] = a; }
int gD1(int x, int y) { return d1[x * m + y]; }
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == 'R')
        sD(i, j, 0);
      else if (s[j] == 'U')
        sD(i, j, 1);
      else if (s[j] == 'L')
        sD(i, j, 2);
      else if (s[j] == 'D')
        sD(i, j, 3);
      else
        sD(i, j, -1);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int d = 0; d < 4; d++) {
        int x = i + dx[d], y = j + dy[d];
        while (0 <= x && x < n && 0 <= y && y < m) {
          if (gD(x, y) >= 0) break;
          x += dx[d];
          y += dy[d];
        }
        if (0 <= x && x < n && 0 <= y && y < m) {
          sP(i, j, d, make_pair(x, y));
        } else
          sP(i, j, d, make_pair(-1, -1));
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int d = gD(i, j);
      if (d < 0) continue;
      for (int x = 0; x < n * m; x++) {
        for (int y = 0; y < 4; y++) p1[x][y] = p[x][y];
      }
      pair<int, int> cur = make_pair(i, j);
      int res = 0;
      while (cur.first >= 0) {
        res++;
        int d = gD(cur.first, cur.second);
        pair<int, int> next = gP1(cur.first, cur.second, d);
        for (int k = 0; k < 4; k++) {
          pair<int, int> q = gP1(cur.first, cur.second, k);
          if (q.first >= 0)
            sP1(q.first, q.second, (k + 2) % 4,
                gP1(cur.first, cur.second, (k + 2) % 4));
        }
        cur = next;
      }
      ans.push_back(res);
    }
  }
  sort(ans.begin(), ans.end());
  int K = 0;
  for (int i = 0; i < (int)ans.size(); i++)
    if (ans[i] == ans.back()) K++;
  cout << ans.back() << ' ' << K << endl;
  return 0;
}
