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 maxn = 20000;
struct node {
  int flow;
  int ff[5];
  int ru;
} mat[maxn];
int n, m;
int kk[500];
int now;
int getup(int id) {
  int ret = -1;
  int k = id - m;
  while (k >= 1) {
    if (mat[k].flow != -1) {
      ret = k;
      break;
    }
    k -= m;
  }
  return ret;
}
int getright(int id) {
  int ret = -1;
  int k = id;
  while (k % m != 0) {
    k = k + 1;
    if (mat[k].flow != -1) {
      ret = k;
      break;
    }
  }
  return ret;
}
int getdown(int id) {
  int ret = -1;
  int k = id + m;
  while (k <= n * m) {
    if (mat[k].flow != -1) {
      ret = k;
      break;
    }
    k += m;
  }
  return ret;
}
int getleft(int id) {
  int ret = -1;
  int k = id;
  while (k % m != 1) {
    k--;
    if (mat[k].flow != -1) {
      ret = k;
      break;
    }
  }
  return ret;
}
int fl[maxn][5];
int ans;
int cnt;
int solve(int id) {
  int ret = 0;
  int k = id;
  int ne;
  int u, d, r, l;
  while (k != -1) {
    ret++;
    ne = mat[k].ff[mat[k].flow];
    u = mat[k].ff[1];
    d = mat[k].ff[3];
    r = mat[k].ff[2];
    l = mat[k].ff[4];
    if (u != -1) {
      mat[u].ff[3] = d;
    }
    if (d != -1) {
      mat[d].ff[1] = u;
    }
    if (r != -1) {
      mat[r].ff[4] = l;
    }
    if (l != -1) {
      mat[l].ff[2] = r;
    }
    k = ne;
  }
  return ret;
}
int main() {
  kk['U'] = 1;
  kk['R'] = 2;
  kk['D'] = 3;
  kk['L'] = 4;
  kk['.'] = -1;
  now = 0;
  cin >> n >> m;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      mat[++now].flow = kk[s[j]];
    }
  }
  for (int i = 1; i <= now; i++) {
    if (mat[i].flow == -1) continue;
    if (n != 1) fl[i][1] = getup(i);
    if (m != 1) fl[i][2] = getright(i);
    if (n != 1) fl[i][3] = getdown(i);
    if (m != 1) fl[i][4] = getleft(i);
    if (m == 1) {
      fl[i][2] = fl[i][4] = -1;
    }
    if (n == 1) {
      fl[i][1] = fl[i][3] = -1;
    }
  }
  for (int i = 1; i <= now; i++) {
    int ne = fl[i][mat[i].flow];
    if (ne != -1) {
      int nne = fl[ne][mat[ne].flow];
      if (nne != i)
        ;
      mat[ne].ru = 1;
    }
  }
  ans = 0;
  for (int i = 1; i <= now; i++) {
    if (mat[i].flow == -1) continue;
    for (int i1 = 1; i1 <= now; i1++) {
      for (int j = 1; j <= 4; j++) {
        mat[i1].ff[j] = fl[i1][j];
      }
    }
    int z = solve(i);
    if (z > ans) {
      ans = z;
      cnt = 1;
    } else if (z == ans) {
      cnt++;
    }
  }
  cout << ans << " " << cnt << endl;
  return 0;
}
