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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <queue>
using namespace std;

typedef long long ll;

const int kNmax = 5000;

struct FenvikTree {
  short data[kNmax];
  FenvikTree() {
    memset(data, 0, sizeof(data));
  }

  int RSQ(int r) const {
    int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += data[r];
	return result;
  }

  int RSQ(int l, int r) const {
    return RSQ(r) - RSQ(l - 1);
  }

  void Add(int i, int d) {
   for (; i < kNmax; i = (i | (i+1)))
		data[i] += d;
  }
};

int BinSearch(int l, int r, const FenvikTree &ft) {
  int start = l;
  while (l < r) {
    int m = (l + r) >> 1;
    int sum = ft.RSQ(start, m);
    if (sum < 1)
      l = m + 1;
    else
      r = m;
  }
  return (ft.RSQ(start, l) == 1 ? l : -1);
}

int BinSearchInv(int l, int r, const FenvikTree &ft) {
  int value = ft.RSQ(l, r);
  int start = l;
  while (l < r) {
    int m = (l + r) >> 1;
    int sum = ft.RSQ(start, m);
    if (sum < value)
      l = m + 1;
    else
      r = m;
  }
  return (ft.RSQ(start, l) == value ? l : -1);
}

FenvikTree h[kNmax], v[kNmax];
string field[kNmax];

void Update(int &res, int &cnt, int &curr) {
  if (curr > res) {
    res = curr;
    cnt = 1;
    return;
  }
  if (res == curr) {
    ++cnt;
  }
}

pair <short, short> q[kNmax * kNmax];
int q_size;

int main() {
  //freopen("input.txt", "r", stdin);
  int n, m;
  cin >> n >> m;
  getline(cin, field[0]);
  for (int i = 0; i < n; ++i)
    getline(cin, field[i]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      if (field[i][j] != '.') {
        h[i].Add(j, 1);
        v[j].Add(i, 1);
      }
  }
  int res = -1, cnt = 0;
  for (int i = 0; i < n; ++i) {    
    for (int j = 0; j < m; ++j) {
      if (field[i][j] == '.') continue;
      q_size = 0;
      int curr = 0;
      int next_i = i, next_j = j;
      while (true) {
        int prev_i = next_i, prev_j = next_j;
        if (field[next_i][next_j] == 'U') {
          int ind = BinSearchInv(0, next_i - 1, v[next_j]);
          if (ind == -1) {
            Update(res, cnt, curr);
            break;
          }
          next_i = ind; //next_j = j;
        } else if (field[next_i][next_j] == 'D') {
          int ind = BinSearch(next_i + 1, n - 1, v[next_j]);
          if (ind == -1) {
            Update(res, cnt, curr);
            break;
          }
          next_i = ind; //next_j = j;        
        } else if (field[next_i][next_j] == 'L') {
          int ind = BinSearchInv(0, next_j - 1, h[next_i]);
          if (ind == -1) {
            Update(res, cnt, curr);
            break;
          }
          /*next_i = i;*/ next_j = ind;
        } else {
         /* int rrr[10];
          for (int ii = 0; ii < m; ++ii) {
            rrr[ii] = h[1].RSQ(0, ii);
          }*/
          int ind = BinSearch(next_j + 1, m - 1, h[next_i]);
          if (ind == -1) {
            Update(res, cnt, curr);
            break;
          }
          /*next_i = i;*/ next_j = ind;
        }
        q[q_size++] = make_pair(prev_i, prev_j);
        h[prev_i].Add(prev_j, -1);
        v[prev_j].Add(prev_i, -1);
        ++curr;
      }
      for (int q_index = 0; q_index < q_size; ++q_index) {
        int i_ind = q[q_index].first;
        int j_ind = q[q_index].second;
        h[i_ind].Add(j_ind, 1);
        v[j_ind].Add(i_ind, 1);
      }
    }
  }
  cout << res << " " << cnt;
  return 0;
}