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 <ctime>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define sqr(a) ((a)*(a))
#define MaxN 5000

int a[MaxN][MaxN];
pair <int, int> ***next; 
pair <int, int> ***prev; 

pair <int, int> ***tnext; 
pair <int, int> ***tprev; 

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
char direct[4] = {'L', 'R', 'U', 'D'};

int n, m;

bool ok(int x, int y)
{
  return (x >= 0 && x < n && y >= 0 && y < m);
}

int ans;
int ans_cnt;

void upd(int probans)
{
  if (probans > ans)
    ans = probans, ans_cnt = 1;
  else if (probans == ans)
    ans_cnt++;
}

void del(int x, int y)
{
  for (int dir = 0; dir < 4; dir++)
  {
    int nex = tnext[x][y][dir].first, ney = tnext[x][y][dir].second;
    int prx = tprev[x][y][dir].first, pry = tprev[x][y][dir].second;
    if (ok(prx, pry))
      tnext[prx][pry][dir] = mp(nex, ney);
    if (ok(nex, ney))
      tprev[nex][ney][dir] = mp(prx, pry);
  }
}

int main(void)
{
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
    {
      char c;
      scanf(" %c", &c);
      a[i][j] = -1;
      for (int k = 0; k < 4; k++)
        if (c == direct[k])
          a[i][j] = k;
    }

  next = new pair <int, int>**[n];
  for (int i = 0; i < n; i++)
    next[i] = new pair <int, int>*[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      next[i][j] = new pair <int, int>[4];

  prev = new pair <int, int>**[n];
  for (int i = 0; i < n; i++)
    prev[i] = new pair <int, int>*[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      prev[i][j] = new pair <int, int>[4];


  tnext = new pair <int, int>**[n];
  for (int i = 0; i < n; i++)
    tnext[i] = new pair <int, int>*[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      tnext[i][j] = new pair <int, int>[4];

  tprev = new pair <int, int>**[n];
  for (int i = 0; i < n; i++)
    tprev[i] = new pair <int, int>*[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      tprev[i][j] = new pair <int, int>[4];


  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int dir = 0; dir < 4; dir++)
      {
        next[i][j][dir] = mp(-1, -1);
        if (a[i][j] != -1)
        {
          int x = i + dx[dir];
          int y = j + dy[dir];
          while (ok(x, y) && a[x][y] == -1)
            x += dx[dir], y += dy[dir];

          if (ok(x, y))
          {
            next[i][j][dir] = mp(x, y);
            prev[x][y][dir] = mp(i, j);
          }
        }
      }



  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
    {
      for (int ii = 0; ii < n; ii++)
        for (int jj = 0; jj < m; jj++)
          for (int dir = 0; dir < 4; dir++)
            tnext[ii][jj][dir] = next[ii][jj][dir], tprev[ii][jj][dir] = prev[ii][jj][dir];
      int x = i, y = j;
      int cnt = 0;
      while (ok(x, y))
      {
        cnt++;
        del(x, y);
        int nx = tnext[x][y][a[x][y]].first, ny = tnext[x][y][a[x][y]].second;
        x = nx, y = ny;
      }
      upd(cnt);
    }

  printf("%d %d\n", ans, ans_cnt);
  return 0;
}
