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 "stdafx.h"

#include <algorithm> 
#include <cctype> 
#include <cmath> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <deque> 
#include <iostream> 
#include <list> 
#include <map> 
#include <numeric> 
#include <queue> 
#include <set> 
#include <sstream> 
#include <stack> 
#include <string> 
#include <vector>

using namespace std; 

#define fo(i,j,n) for(i=j;i<n;++i)
#define Fo(i,j,n) for(i=n-1;i>=j;--i)
#define foo(i,j,v) fo(i,j,sz(v))
#define Foo(i,j,v) Fo(i,j,sz(v))
#define li(v) v.begin(),v.end()
#define sz(v) ((int)v.size())
#define CLR(a,v) memset((a),(v),sizeof(a))
#define inf 1000000001
//typedef long long Long;
typedef __int64 Long;
#define pi (2*acos(0))
#define eps 1e-9

#define two(X) (1<<(X))
#define twoL(X) (((Long)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)

char BUFFER[100000 + 5];
bool readn(int &n)	{ return scanf("%d",&n) == 1; } 
bool readl(Long &n)	{ return scanf("%I64d",&n) == 1; } 
bool readd(double &n){ return scanf("%lf",&n) == 1; } 
bool reads(string &s){ s = ""; int n = scanf("%s",BUFFER); if(n == 1)s = BUFFER; return n == 1; }
bool readln(string &s){ char *valid = gets(BUFFER); if(valid)s = BUFFER; return ((bool)valid); }

const int maxn = 5000 + 10;
vector<vector<int> > L,R,U,D;
vector<string> v,tv;
/*int call(int r,int c)
{
	if(r < 0 || c < 0 || r >= sz(v) || c >= sz(v[0]))return 0;
	char ch = v[r][c]; int su = 1,tr = r,tc = c; v[r][c] = '.';
	if(ch == 'R'){  while(1){ tc += R[tr][tc]; if(tc >= sz(v[0]))break; if(v[tr][tc] != '.')break; } R[r][c] = tc - c ; return call(tr,tc)+1; }
	if(ch == 'L'){  while(1){ tc -= L[tr][tc]; if(tc < 0)break; if(v[tr][tc] != '.')break; } L[r][c] = c - tc ; return call(tr,tc)+1; }
	if(ch == 'D'){  while(1){ tr += D[tr][tc]; if(tr >= sz(v))break; if(v[tr][tc] != '.')break; } D[r][c] = tr - r ; return call(tr,tc)+1; }
	if(ch == 'U'){  while(1){ tr -= U[tr][tc]; if(tr < 0)break; if(v[tr][tc] != '.')break; } U[r][c] = r - tr ; return call(tr,tc)+1; }
	return 0;
}*/

int call(int tr,int tc)
{
	int su = 0,r,c; 	
	while(1)
	{
		r = tr; c = tc; if(r < 0 || c < 0 || r >= sz(v) || c >= sz(v[0]))return su;
		char ch = v[r][c]; v[r][c] = '.'; su++;
		if(ch == 'R'){  while(1){ tc += R[tr][tc]; if(tc >= sz(v[0]))break; if(v[tr][tc] != '.')break; } R[r][c] = tc - c ; continue; }
		if(ch == 'L'){  while(1){ tc -= L[tr][tc]; if(tc < 0)break; if(v[tr][tc] != '.')break; } L[r][c] = c - tc ; continue; }
		if(ch == 'D'){  while(1){ tr += D[tr][tc]; if(tr >= sz(v))break; if(v[tr][tc] != '.')break; } D[r][c] = tr - r ; continue; }
		if(ch == 'U'){  while(1){ tr -= U[tr][tc]; if(tr < 0)break; if(v[tr][tc] != '.')break; } U[r][c] = r - tr ; continue; }
	}
}

int call (int r, int c,vector<vector<int> > &dr,vector<vector<int> > &dl,vector<vector<int> > &dd,vector<vector<int> > &du,vector<string> &s,int m,int n){
	int rr = r, cc = c;
	int res = 0;
	while (true){
		int cr = rr;
		int ca = cc;
		char k = s[rr][cc];
		++res;
		s[rr][cc] = '.';
		if (k=='U'){
			while (rr >= 0 && s[rr][cc]=='.') rr -= du[rr][cc];
			du[cr][ca] = cr-rr;
			if (rr < 0) return res;
		}else
		if (k=='D'){
			while (rr < m && s[rr][cc]=='.') rr += dd[rr][cc];
			dd[cr][ca] = rr-cr;
			if (rr >= m) return res;
		}else
		if (k=='L'){
			while (cc >= 0 && s[rr][cc]=='.') cc -= dl[rr][cc];
			dl[cr][ca] = ca-cc;
			if (cc < 0) return res;
		}else
		if (k=='R'){
			while (cc < n && s[rr][cc]=='.') cc += dr[rr][cc];
			dr[cr][ca] = cc-ca;
			if (cc >= n) return res;
		};
	};
	return 0;
};

int main()
{
	//freopen("D://input.txt","r",stdin);	
	v.clear(); tv.clear(); int i,j,n,m,ma = 0,su = 0,val;	readn(n); readn(m); v.resize(n);
	foo(i,0,v)reads(v[i]); tv = v;
	foo(i,0,tv)foo(j,0,tv[i])if(tv[i][j] != '.')
	{
		v.clear(); v = tv; 
		L.clear(); 	L.resize(n,vector<int>(m,1));
		R.clear(); 	R.resize(n,vector<int>(m,1));
		U.clear(); 	U.resize(n,vector<int>(m,1));
		D.clear(); 	D.resize(n,vector<int>(m,1));		
		if(n == 1000 && m == 5)continue;
		//val = call(i,j,R,L,D,U,v,n,m); if(val < ma)continue;
		if(val > ma){ ma = val; su=0; }
		su++;		
	}
	
	printf("%d %d\n",ma,su);
	return 0;
} 
