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 <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
long long seed = std::chrono::steady_clock::now().time_since_epoch().count();
mt19937_64 rng(seed);
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
long long n, m, k, q, l, r, x, y, z;
const long long template_array_size = 1e6 + 8432;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
long long ans = 0;
const long long dr[4] = {0, 0, 1, -1};
const long long dc[4] = {-1, 1, 0, 0};
long long gv(char c) {
  if (c == 'L') return 0;
  if (c == 'R') return 1;
  if (c == 'D') return 2;
  return 3;
}
bool valid(long long r, long long c) {
  return r >= 0 && r < n && c >= 0 && c < m;
}
void solve(int tc = 0) {
  cin >> n >> m;
  long long mat[n][m];
  for (long long i = 0; i < n; i++) {
    cin >> second;
    for (long long j = 0; j < m; j++) {
      if (second[j] == '.')
        mat[i][j] = -1;
      else
        mat[i][j] = gv(second[j]);
    }
  }
  pair<long long, long long> nxt[n][m][4];
  long long v = -1, cv = 0;
  for (long long sr = 0; sr < n; sr++) {
    for (long long sc = 0; sc < m; sc++) {
      if (mat[sr][sc] == -1) continue;
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
          for (long long d = 0; d < 4; d++) {
            long long ni = i + dr[d], nj = j + dc[d];
            nxt[i][j][d] = make_pair(ni, nj);
          }
        }
      }
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
          if (mat[i][j] == -1) {
            pair<long long, long long> l = nxt[i][j][0], r = nxt[i][j][1];
            if (valid(l.first, l.second)) nxt[l.first][l.second][1] = r;
            if (valid(r.first, r.second)) nxt[r.first][r.second][0] = l;
            pair<long long, long long> d = nxt[i][j][2], u = nxt[i][j][3];
            if (valid(d.first, d.second)) nxt[d.first][d.second][3] = u;
            if (valid(u.first, u.second)) nxt[u.first][u.second][2] = d;
          }
        }
      }
      pair<long long, long long> pos = make_pair(sr, sc);
      long long cnt = 0;
      while (valid(pos.first, pos.second)) {
        pair<long long, long long> l = nxt[pos.first][pos.second][0],
                                   r = nxt[pos.first][pos.second][1];
        if (valid(l.first, l.second)) nxt[l.first][l.second][1] = r;
        if (valid(r.first, r.second)) nxt[r.first][r.second][0] = l;
        pair<long long, long long> d = nxt[pos.first][pos.second][2],
                                   u = nxt[pos.first][pos.second][3];
        if (valid(d.first, d.second)) nxt[d.first][d.second][3] = u;
        if (valid(u.first, u.second)) nxt[u.first][u.second][2] = d;
        pos = nxt[pos.first][pos.second][mat[pos.first][pos.second]];
        ++cnt;
      }
      if (cnt > v) {
        v = cnt;
        cv = 1;
      } else if (cnt == v)
        ++cv;
    }
  }
  cout << v << " " << cv << '\n';
}
int main() {
  { ios_base::sync_with_stdio(false); }
  { cin.tie(NULL); }
  cout << setprecision(12) << fixed;
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}
