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;
struct node {
  node *next, *oth, *prev;
  int x, y;
  bool type;
  node(int x, int y, bool type) : x(x), y(y), type(type) {
    next = oth = prev = 0;
  }
  node() {
    x = y = -1;
    next = oth = prev = 0;
  }
};
node* xs[5100];
node* ys[5100];
vector<char> s[5100];
vector<node*> xnode[5100];
vector<node*> ynode[5100];
int n, m;
void del(node* x) {
  x->prev->next = x->next;
  x->next->prev = x->prev;
}
void init() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] != '.') {
        node* tmp = new node(i, j, 0);
        node* tmp2 = new node(i, j, 1);
        (tmp->oth = tmp2)->oth = tmp;
        xnode[i].push_back(tmp);
        ynode[j].push_back(tmp2);
      }
}
node mem[30000];
int memptr;
node* getnode() {
  mem[memptr] = node();
  return &mem[memptr++];
}
void build() {
  memptr = 0;
  for (int i = 0; i < n; i++) {
    xs[i] = getnode();
    node* t = xs[i];
    for (int j = 0; j < xnode[i].size(); j++) {
      t->next = xnode[i][j];
      xnode[i][j]->prev = t;
      t = xnode[i][j];
    }
    t->next = getnode();
    t->next->prev = t;
  }
  for (int i = 0; i < m; i++) {
    ys[i] = getnode();
    node* t = ys[i];
    for (int j = 0; j < ynode[i].size(); j++) {
      t->next = ynode[i][j];
      ynode[i][j]->prev = t;
      t = ynode[i][j];
    }
    t->next = getnode();
    t->next->prev = t;
  }
}
void read() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    s[i].resize(m);
    for (int j = 0; j < m; j++) scanf(" %c ", &s[i][j]);
  }
}
int calc(int x, int y) {
  build();
  node* cur = xs[x];
  for (; cur->y != y; cur = cur->next)
    ;
  int cnt = 0;
  for (; cur->x != -1;) {
    cnt++;
    int x = cur->x;
    int y = cur->y;
    node* next;
    if (s[x][y] == 'L' || s[x][y] == 'R')
      if (cur->type) cur = cur->oth;
    if (s[x][y] == 'U' || s[x][y] == 'D')
      if (!cur->type) cur = cur->oth;
    if (s[x][y] == 'L' || s[x][y] == 'U')
      next = cur->prev;
    else
      next = cur->next;
    del(cur->oth);
    del(cur);
    cur = next;
  }
  return cnt;
}
int main() {
  read();
  init();
  int best = 0, bcnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] != '.') {
        int tmp = calc(i, j);
        if (tmp > best)
          best = tmp, bcnt = 1;
        else if (tmp == best)
          bcnt++;
      }
  cout << best << " " << bcnt << endl;
  return 0;
}
