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;
struct pkt {
  int x, y;
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<string> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  vector<vector<int> > a(n, vector<int>(m, -1));
  for (int k = 0; k < n; ++k) {
    for (int l = 1; l < m; ++l) {
      if (p[k][l - 1] != '.')
        a[k][l] = l - 1;
      else
        a[k][l] = a[k][l - 1];
    }
  }
  vector<vector<int> > b(n, vector<int>(m, -1));
  for (int k = 0; k < n; ++k) {
    for (int l = m - 2; l >= 0; --l) {
      if (p[k][l + 1] != '.')
        b[k][l] = l + 1;
      else
        b[k][l] = b[k][l + 1];
    }
  }
  vector<vector<int> > c(n, vector<int>(m, -1));
  for (int l = 0; l < m; ++l) {
    for (int k = 1; k < n; ++k) {
      if (p[k - 1][l] != '.')
        c[k][l] = k - 1;
      else
        c[k][l] = c[k - 1][l];
    }
  }
  vector<vector<int> > d(n, vector<int>(m, -1));
  for (int l = 0; l < m; ++l) {
    for (int k = n - 2; k >= 0; --k) {
      if (p[k + 1][l] != '.')
        d[k][l] = k + 1;
      else
        d[k][l] = d[k + 1][l];
    }
  }
  vector<vector<int> > L, P, G, D;
  L = a;
  P = b;
  G = c;
  D = d;
  int odp = 0, il = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (p[i][j] == '.') continue;
      int dl = 1;
      pkt akt = {i, j};
      vector<pkt> z;
      while (true) {
        pkt nast;
        if (p[akt.x][akt.y] == 'L')
          nast = {akt.x, L[akt.x][akt.y]};
        else {
          if (p[akt.x][akt.y] == 'R')
            nast = {akt.x, P[akt.x][akt.y]};
          else {
            if (p[akt.x][akt.y] == 'U')
              nast = {G[akt.x][akt.y], akt.y};
            else {
              if (p[akt.x][akt.y] == 'D') nast = {D[akt.x][akt.y], akt.y};
            }
          }
        }
        if (nast.x == -1 || nast.y == -1) break;
        ++dl;
        pkt le = {akt.x, L[akt.x][akt.y]};
        pkt pr = {akt.x, P[akt.x][akt.y]};
        if (le.x != -1 && le.y != -1) P[le.x][le.y] = pr.y;
        if (pr.x != -1 && pr.y != -1) L[pr.x][pr.y] = le.y;
        pkt go = {G[akt.x][akt.y], akt.y};
        pkt dol = {D[akt.x][akt.y], akt.y};
        if (dol.x != -1 && dol.y != -1) G[dol.x][dol.y] = go.x;
        if (go.x != -1 && go.y != -1) D[go.x][go.y] = dol.x;
        akt = nast;
        z.push_back(le);
        z.push_back(pr);
        z.push_back(go);
        z.push_back(dol);
      }
      if (dl > odp) {
        odp = dl;
        il = 1;
      } else {
        if (dl == odp) ++il;
      }
      for (int k = 0; k < z.size(); ++k) {
        if (z[k].x == -1 || z[k].y == -1) continue;
        L[z[k].x][z[k].y] = a[z[k].x][z[k].y];
        P[z[k].x][z[k].y] = b[z[k].x][z[k].y];
        G[z[k].x][z[k].y] = c[z[k].x][z[k].y];
        D[z[k].x][z[k].y] = d[z[k].x][z[k].y];
      }
    }
  }
  cout << odp << " " << il;
  return 0;
}
