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;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
enum type { UP, DOWN, LEFT, RIGHT };
struct V {
  int l, r, u, d;
  type t;
};
V v[5000];
int sz;
int h, w;
void make_graph(vector<vector<int> > &node, vector<string> &in) {
  vector<int> line(w, -1);
  int left;
  sz = 0;
  for (int i = 0; i < h; i++) {
    left = -1;
    for (int j = 0; j < w; j++)
      if (in[i][j] == '.')
        node[i][j] = -1;
      else {
        node[i][j] = sz;
        v[sz].u = line[j];
        if (line[j] >= 0) v[line[j]].d = sz;
        line[j] = sz;
        v[sz].l = left;
        if (left >= 0) v[left].r = sz;
        left = sz;
        const char *s = "UDLR";
        for (int k = 0; k < 4; k++)
          if (s[k] == in[i][j]) v[sz].t = (type)k;
        v[sz].d = v[sz].r = -1;
        sz++;
      }
  }
}
void run() {
  cin >> h >> w;
  vector<string> in(h);
  for (int i = 0; i < h; i++) cin >> in[i];
  vector<int> line(w, -1);
  vector<vector<int> > node(h, vector<int>(w));
  int ans = -1, ansi = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (in[i][j] != '.') {
        make_graph(node, in);
        int cur = node[i][j];
        int num = 0;
        for (; cur != -1;) {
          num++;
          int l = v[cur].l, r = v[cur].r, d = v[cur].d, u = v[cur].u;
          if (v[cur].t == UP)
            cur = v[cur].u;
          else if (v[cur].t == DOWN)
            cur = v[cur].d;
          else if (v[cur].t == LEFT)
            cur = v[cur].l;
          else
            cur = v[cur].r;
          if (l >= 0) v[l].r = r;
          if (r >= 0) v[r].l = l;
          if (u >= 0) v[u].d = d;
          if (d >= 0) v[d].u = u;
        }
        if (ans < num) ans = num, ansi = 0;
        if (ans == num) ansi++;
      }
  cout << ans << " " << ansi << endl;
}
int main() { run(); }
