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;
int n, m;
int dir[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
unordered_map<char, int> c_to_idx{{'L', 0}, {'U', 1}, {'R', 2}, {'D', 3}};
int is_ok(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
struct Node {
 public:
  pair<int, int> cur;
  pair<int, int> nxt_dir[4];
  Node(int x, int y) : cur{x, y} {
    for (int ctr1 = 0; ctr1 < 4; ++ctr1)
      nxt_dir[ctr1] = {x + dir[ctr1][0], y + dir[ctr1][1]};
  }
  void expand(vector<vector<Node>>& mapa) {
    for (int ctr1 = 0; ctr1 < 4; ++ctr1)
      if (is_ok(nxt_dir[ctr1].first, nxt_dir[ctr1].second))
        mapa[nxt_dir[ctr1].first][nxt_dir[ctr1].second]
            .nxt_dir[(ctr1 + 2) % 4] = nxt_dir[(ctr1 + 2) % 4];
  }
  void compress(vector<vector<Node>>& mapa) {
    for (int ctr1 = 0; ctr1 < 4; ++ctr1)
      if (is_ok(nxt_dir[ctr1].first, nxt_dir[ctr1].second))
        mapa[nxt_dir[ctr1].first][nxt_dir[ctr1].second]
            .nxt_dir[(ctr1 + 2) % 4] = cur;
  }
};
vector<vector<Node>> mat;
vector<string> mapa;
int count(pair<int, int> a) {
  pair<int, int> nxt =
      mat[a.first][a.second].nxt_dir[c_to_idx[mapa[a.first][a.second]]];
  if (!is_ok(nxt.first, nxt.second)) return 1;
  mat[a.first][a.second].expand(mat);
  int rez = 1 + count(nxt);
  mat[a.first][a.second].compress(mat);
  return rez;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  string s;
  for (int ctr1 = 0; ctr1 < n; ++ctr1) cin >> s, mapa.push_back(s);
  for (int ctr1 = 0; ctr1 < n; ++ctr1) {
    vector<Node> tmp;
    for (int ctr2 = 0; ctr2 < m; ++ctr2) tmp.emplace_back(ctr1, ctr2);
    mat.push_back(tmp);
  }
  for (int ctr1 = 0; ctr1 < n; ++ctr1) {
    for (int ctr2 = 0; ctr2 < m; ++ctr2) {
      if (mapa[ctr1][ctr2] == '.') mat[ctr1][ctr2].expand(mat);
    }
  }
  pair<int, int> rez = {0, 0};
  for (int ctr1 = 0; ctr1 < n; ++ctr1) {
    for (int ctr2 = 0; ctr2 < m; ++ctr2) {
      if (mapa[ctr1][ctr2] != '.') {
        int c_rez = count({ctr1, ctr2});
        if (c_rez == rez.first)
          ++rez.second;
        else if (c_rez > rez.first)
          rez = {c_rez, 1};
      }
    }
  }
  cout << rez.first << ' ' << rez.second << '\n';
  return 0;
}
