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;
vector<string> f;
int N, M;
int visited[5002];
int jump_left[5002];
int jump_right[5002];
int jump_up[5002];
int jump_down[5002];
int get_jump_up(int i, int j) { return jump_up[i * M + j]; }
void set_jump_up(int i, int j, int value) { jump_up[i * M + j] = value; }
int get_jump_down(int i, int j) { return jump_down[i * M + j]; }
void set_jump_down(int i, int j, int value) { jump_down[i * M + j] = value; }
int get_jump_right(int i, int j) { return jump_right[i * M + j]; }
void set_jump_right(int i, int j, int value) { jump_right[i * M + j] = value; }
int get_jump_left(int i, int j) { return jump_left[i * M + j]; }
void set_jump_left(int i, int j, int value) { jump_left[i * M + j] = value; }
int get_visited(int i, int j) { return visited[i * M + j]; }
void set_visited(int i, int j, int value) { visited[i * M + j] = value; }
int get_next_right(int i_curr, int j_curr) {
  int j_next = j_curr + max(get_jump_right(i_curr, j_curr), 1);
  if (j_next >= M) {
    set_jump_right(i_curr, j_curr, j_next - j_curr);
    return j_next;
  }
  if (f[i_curr][j_next] == '.' || get_visited(i_curr, j_next)) {
    int res = get_next_right(i_curr, j_next);
    set_jump_right(i_curr, j_curr, res - j_curr);
    return res;
  }
  return j_next;
}
int get_next_left(int i_curr, int j_curr) {
  int j_next = j_curr - max(get_jump_left(i_curr, j_curr), 1);
  if (j_next < 0) {
    set_jump_left(i_curr, j_curr, j_next - j_curr);
    return j_next;
  }
  if (f[i_curr][j_next] == '.' || get_visited(i_curr, j_next)) {
    int res = get_next_left(i_curr, j_next);
    set_jump_left(i_curr, j_curr, j_curr - res);
    return res;
  }
  return j_next;
}
int main(int argc, char* argv[]) {
  string str;
  getline(cin, str);
  sscanf(str.c_str(), "%d %d", &N, &M);
  for (int i = 0; i < (int)(N); ++i) {
    getline(cin, str);
    f.push_back(str);
  }
  int N = f.size();
  int M = f[0].size();
  int max_path = 0;
  int max_path_count = 1;
  for (int i = 0; i < (int)(N); ++i) {
    for (int j = 0; j < (int)(M); ++j) {
      if (f[i][j] == '.') continue;
      memset(visited, 0, sizeof(visited));
      memset(jump_left, 0, sizeof(jump_left));
      memset(jump_right, 0, sizeof(jump_right));
      memset(jump_up, 0, sizeof(jump_up));
      memset(jump_down, 0, sizeof(jump_down));
      int i_curr = i, j_curr = j;
      int path = 1;
      while (true) {
        set_visited(i_curr, j_curr, true);
        if (f[i_curr][j_curr] == 'U') {
          int k = i_curr - max(get_jump_up(i_curr, j_curr), 1);
          while (k >= 0 && (f[k][j_curr] == '.' || get_visited(k, j_curr))) {
            k -= max(get_jump_up(k, j_curr), 1);
          }
          set_jump_up(i_curr, j_curr, i_curr - k);
          if (k >= 0) {
            path++;
            i_curr = k;
          } else
            break;
        } else if (f[i_curr][j_curr] == 'D') {
          int k = i_curr + max(get_jump_down(i_curr, j_curr), 1);
          while (k < N && (f[k][j_curr] == '.' || get_visited(k, j_curr))) {
            k += max(get_jump_down(k, j_curr), 1);
          }
          set_jump_down(i_curr, j_curr, k - i_curr);
          if (k < N) {
            path++;
            i_curr = k;
          } else
            break;
        } else if (f[i_curr][j_curr] == 'L') {
          int k = get_next_left(i_curr, j_curr);
          if (k >= 0) {
            path++;
            j_curr = k;
          } else
            break;
        } else if (f[i_curr][j_curr] == 'R') {
          int k = get_next_right(i_curr, j_curr);
          if (k < M) {
            path++;
            j_curr = k;
          } else
            break;
        }
      }
      if (path > max_path) {
        max_path = path;
        max_path_count = 1;
      } else if (path == max_path) {
        max_path_count++;
      }
    }
  }
  cout << max_path << " " << max_path_count << "\n";
  int temp;
  std::cin >> temp;
}
