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;
template <class T>
inline void debug(const T& c) {
  cout << "{";
  for (__typeof((c.begin())) it = (c).begin(); it != (c).end(); ++it)
    cout << *it << ",";
  cout << "}" << endl;
}
template <class T>
inline void setmin(T& a, const T& b) {
  if (b < a) a = b;
}
template <class T>
inline void setmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <class T>
inline int size(const T& c) {
  return (int)c.size();
}
template <class T>
inline string to_str(const T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <class T>
inline T sqr(const T& a) {
  return a * a;
}
template <class T>
T next() {
  T x;
  cin >> x;
  return x;
}
int II() {
  int x;
  scanf("%d", &x);
  return x;
}
char tab[5009][5009];
vector<pair<int, int> > dp[4][5009];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int n, m;
int trans[250];
void odnow() {
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      for (int k = 0; k < (4); ++k) {
        int i2 = i + dx[k];
        int j2 = j + dy[k];
        if (tab[i2][j2] != '.' && tab[i2][j2] != 0)
          dp[k][i][j] = make_pair(i2, j2);
        else
          dp[k][i][j] = dp[k][i2][j2];
      }
    }
}
void usun(int a, int b) {
  for (int k = 0; k < (4); ++k) {
    int a0 = dp[k][a][b].first;
    int b0 = dp[k][a][b].second;
    dp[(k + 2) & 3][a0][b0] = dp[(k + 2) & 3][a][b];
  }
}
int go(int a, int b) {
  int ile = 0;
  while (a != 0 && b != 0) {
    int k = trans[tab[a][b]];
    int nx = dp[k][a][b].first;
    int ny = dp[k][a][b].second;
    usun(a, b);
    a = nx;
    b = ny;
    ++ile;
  }
  return ile;
}
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = (1); i <= (n); ++i) {
    gets(&tab[i][1]);
  }
  for (int i = (0); i <= (n + 1); ++i)
    for (int j = 0; j < (4); ++j)
      dp[j][i] = vector<pair<int, int> >(m + 9, make_pair(0, 0));
  trans['U'] = 3;
  trans['D'] = 1;
  trans['L'] = 2;
  trans['R'] = 0;
  int best = 0;
  int ile = 0;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      if (tab[i][j] == '.') continue;
      odnow();
      int wynik = go(i, j);
      if (best == wynik)
        ++ile;
      else if (best < wynik) {
        best = wynik;
        ile = 1;
      }
    }
  printf("%d %d\n", best, ile);
  return 0;
}
