#include <bits/stdc++.h>
using namespace std;
int n, m;
char c[5010][5001] = {};
short p[5010][550][4] = {};
short q[5010][550][4] = {};
short pi[550][5010][4] = {};
short qi[550][5010][4] = {};
vector<int> c1;
vector<int> c2;
vector<int> c3;
vector<int> c4;
void init() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      p[i][j][0] = p[i - 1][j][0];
      p[i][j][2] = p[i][j - 1][2];
      if (c[i - 1][j] != '.') p[i][j][0] = i - 1;
      if (c[i][j - 1] != '.') p[i][j][2] = j - 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      p[i][j][1] = p[i + 1][j][1];
      p[i][j][3] = p[i][j + 1][3];
      if (c[i + 1][j] != '.') p[i][j][1] = i + 1;
      if (c[i][j + 1] != '.') p[i][j][3] = j + 1;
    }
  }
}
void pp() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= 3; k++) {
        q[i][j][k] = p[i][j][k];
      }
    }
  }
}
int ff(int x, int y) {
  int ans = 0;
  c1.clear();
  c2.clear();
  c3.clear();
  c4.clear();
  while (1) {
    ans++;
    int w;
    if (c[x][y] == 'U') w = q[x][y][0];
    if (c[x][y] == 'D') w = q[x][y][1];
    if (c[x][y] == 'L') w = q[x][y][2];
    if (c[x][y] == 'R') w = q[x][y][3];
    if (w == 0) break;
    int e[4];
    for (int i = 0; i <= 3; i++) e[i] = q[x][y][i];
    if (e[0] != 0) {
      c1.push_back(e[0]);
      c2.push_back(y);
      c3.push_back(1);
      c4.push_back(q[e[0]][y][1]);
      q[e[0]][y][1] = e[1];
    }
    if (e[1] != 0) {
      c1.push_back(e[1]);
      c2.push_back(y);
      c3.push_back(0);
      c4.push_back(q[e[1]][y][0]);
      q[e[1]][y][0] = e[0];
    }
    if (e[2] != 0) {
      c1.push_back(x);
      c2.push_back(e[2]);
      c3.push_back(3);
      c4.push_back(q[x][e[2]][3]);
      q[x][e[2]][3] = e[3];
    }
    if (e[3] != 0) {
      c1.push_back(x);
      c2.push_back(e[3]);
      c3.push_back(2);
      c4.push_back(q[x][e[3]][2]);
      q[x][e[3]][2] = e[2];
    }
    if (c[x][y] == 'U')
      x = e[0];
    else if (c[x][y] == 'D')
      x = e[1];
    else if (c[x][y] == 'L')
      y = e[2];
    else if (c[x][y] == 'R')
      y = e[3];
  }
  for (int i = c1.size() - 1; i >= 0; i--) {
    q[c1[i]][c2[i]][c3[i]] = c4[i];
  }
  return ans;
}
void init1() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      pi[i][j][0] = pi[i - 1][j][0];
      pi[i][j][2] = pi[i][j - 1][2];
      if (c[i - 1][j] != '.') pi[i][j][0] = i - 1;
      if (c[i][j - 1] != '.') pi[i][j][2] = j - 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      pi[i][j][1] = pi[i + 1][j][1];
      pi[i][j][3] = pi[i][j + 1][3];
      if (c[i + 1][j] != '.') pi[i][j][1] = i + 1;
      if (c[i][j + 1] != '.') pi[i][j][3] = j + 1;
    }
  }
}
void pp1() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= 3; k++) {
        qi[i][j][k] = pi[i][j][k];
      }
    }
  }
}
int ff1(int x, int y) {
  int ans = 0;
  c1.clear();
  c2.clear();
  c3.clear();
  c4.clear();
  while (1) {
    ans++;
    int w;
    if (c[x][y] == 'U') w = qi[x][y][0];
    if (c[x][y] == 'D') w = qi[x][y][1];
    if (c[x][y] == 'L') w = qi[x][y][2];
    if (c[x][y] == 'R') w = qi[x][y][3];
    if (w == 0) break;
    int e[4];
    for (int i = 0; i <= 3; i++) e[i] = qi[x][y][i];
    if (e[0] != 0) {
      c1.push_back(e[0]);
      c2.push_back(y);
      c3.push_back(1);
      c4.push_back(qi[e[0]][y][1]);
      qi[e[0]][y][1] = e[1];
    }
    if (e[1] != 0) {
      c1.push_back(e[1]);
      c2.push_back(y);
      c3.push_back(0);
      c4.push_back(qi[e[1]][y][0]);
      qi[e[1]][y][0] = e[0];
    }
    if (e[2] != 0) {
      c1.push_back(x);
      c2.push_back(e[2]);
      c3.push_back(3);
      c4.push_back(qi[x][e[2]][3]);
      qi[x][e[2]][3] = e[3];
    }
    if (e[3] != 0) {
      c1.push_back(x);
      c2.push_back(e[3]);
      c3.push_back(2);
      c4.push_back(qi[x][e[3]][2]);
      qi[x][e[3]][2] = e[2];
    }
    if (c[x][y] == 'U')
      x = e[0];
    else if (c[x][y] == 'D')
      x = e[1];
    else if (c[x][y] == 'L')
      y = e[2];
    else if (c[x][y] == 'R')
      y = e[3];
  }
  for (int i = c1.size() - 1; i >= 0; i--) {
    qi[c1[i]][c2[i]][c3[i]] = c4[i];
  }
  return ans;
}
char cc;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) c[i][j] = '.';
  }
  cc = getchar();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cc = getchar();
      c[i][j] = cc;
    }
    cc = getchar();
  }
  int ansx = 0;
  int ansy = 0;
  if (n >= m) {
    init();
    pp();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (c[i][j] == '.') continue;
        int tt = ff(i, j);
        if (tt > ansx) {
          ansx = tt;
          ansy = 1;
        } else if (tt == ansx) {
          ansy++;
        }
      }
    }
  } else {
    init1();
    pp1();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (c[i][j] == '.') continue;
        int tt = ff1(i, j);
        if (tt > ansx) {
          ansx = tt;
          ansy = 1;
        } else if (tt == ansx) {
          ansy++;
        }
      }
    }
  }
  printf("%d %d\n", ansx, ansy);
  return 0;
}
