#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;
}
