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;
typedef pair<long long, long long> ll;
typedef vector<long long> vl;
typedef vector<ll> vll;
typedef vector<vl> vvl;
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
  if (v.size() > 0) o << v[0];
  for (unsigned i = 1; i < v.size(); i++) o << " " << v[i];
  return o << "\n";
}
template <typename U, typename V>
ostream &operator<<(ostream &o, pair<U, V> p) {
  return o << "(" << p.first << ", " << p.second << ") ";
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (unsigned i = 0; i < v.size(); i++) in >> v[i];
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &p) {
  in >> p.first;
  in >> p.second;
  return in;
}
struct node {
  long long l, r, d, u;
  char v;
  node(char value, long long _r, long long _d, long long _l, long long _u)
      : l(_l), r(_r), d(_d), u(_u), v(value) {}
  void print() {
    cout << v << " ";
    cout << "l"
         << "=" << l << " "
         << "r"
         << "=" << r << " "
         << "d"
         << "=" << d << " "
         << "u"
         << "=" << u << "\n";
    ;
  }
};
vector<vector<node>> a;
long long n, m;
void del(long long x, long long y) {
  a[x][a[x][y].l].r = a[x][y].r;
  a[x][a[x][y].r].l = a[x][y].l;
  a[a[x][y].d][y].u = a[x][y].u;
  a[a[x][y].u][y].d = a[x][y].d;
}
void add(long long x, long long y) {
  a[x][a[x][y].l].r = y;
  a[x][a[x][y].r].l = y;
  a[a[x][y].d][y].u = x;
  a[a[x][y].u][y].d = x;
}
long long dfs(long long x, long long y) {
  if (x == 0 or x == n + 1 or y == 0 or y == m + 1) return 0;
  del(x, y);
  long long res = 0;
  long long i = x;
  long long j = y;
  if (a[i][j].v == 'U')
    res = dfs(a[i][j].u, y);
  else if (a[i][j].v == 'D')
    res = dfs(a[i][j].d, y);
  else if (a[i][j].v == 'R')
    res = dfs(x, a[i][j].r);
  else if (a[i][j].v == 'L')
    res = dfs(x, a[i][j].l);
  add(x, y);
  return res + 1;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  cin >> n >> m;
  a.resize(n + 2, vector<node>(m + 2, node('X', m, n, 0, 0)));
  for (long long i = (1); i < (long long)n + 1; i++)
    for (long long j = (1); j < (long long)m + 1; j++) cin >> a[i][j].v;
  for (long long i = (1); i < (long long)n + 1; i++) {
    long long p = 0;
    for (long long(j) = 1; (j) < (m + 2); (j)++) {
      if (a[i][j].v != '.') {
        a[i][j].l = p;
        a[i][p].r = j;
        p = j;
      }
    }
  }
  for (long long i = (1); i < (long long)m + 1; i++) {
    long long p = 0;
    for (long long(j) = 1; (j) < (n + 2); (j)++) {
      if (a[j][i].v != '.') {
        a[j][i].u = p;
        a[p][i].d = j;
        p = j;
      }
    }
  }
  long long ans = 0;
  long long cnt = 0;
  for (long long i = (1); i < (long long)n + 1; i++)
    for (long long j = (1); j < (long long)m + 1; j++)
      if (a[i][j].v != '.') {
        long long x = dfs(i, j);
        if (x > ans)
          ans = x, cnt = 1;
        else if (x == ans)
          cnt++;
      }
  cout << ans << " " << cnt << "\n";
  return 0;
}
