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;
#define ll long long
#define ull unsigned long long
#define ld long double
#define f first
#define s second
#define PI acos(-1)
#define CS ios_base::sync_with_stdio(0);cin.tie(0);
const int mod = (int)1e9 + 7;
const int N = 1e6 + 100;
const ll inf = 1e18 + 100;
ld EPS = 1e-18;
typedef vector < vector < ll > > mat;
const int INF = 2000000000;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dxx[] = {0, 0, -1, -1, -1, 1, 1, 1};
int dyy[] = {1, -1, 0, 1, -1, 0, 1, -1};

bool valid( int x, int y, int nn, int mm ){
	return (x >= 0 && y >= 0 && x < nn && y < mm);
}

ll fastpow( ll a, ll b ){
	if( !b )
		return 1;
	if( b % 2 )
		return (a * fastpow ( a, b - 1 )) % mod;
	return fastpow ((a * a) % mod, b / 2 ) % mod;
}

ll divv( ll a, ll b ){
	return (a % mod) * (fastpow ( b, mod - 2 ) % mod);
}
int n,m,id=1;
vector<vector<char>>arr;
vector<vector<int>>vis;
int solve(int i,int j)
{
	if(arr[i][j]=='U')
	{
		for(int x=i-1;x>=0;x--)
		{
			if(arr[x][j]!='.'&&vis[x][j]!=id)
			{
				vis[x][j]=id;
				return 1+solve (x,j);
			}
		}
	}else if(arr[i][j]=='D')
	{
		for(int x=i+1;x<n;x++)
		{
			if(arr[x][j]!='.'&&vis[x][j]!=id)
			{
				vis[x][j]=id;
				return 1+solve (x,j);
			}
		}
	}else if(arr[i][j]=='L')
	{
		for(int x=j-1;x>=0;x--)
		{
			if(arr[i][x]!='.'&&vis[i][x]!=id)
			{
				vis[i][x]=id;
				return 1+solve(i,x);
			}
		}
	}else if(arr[i][j]=='R')
	{
		for(int x=j+1;x<m;x++)
		{
			if(arr[i][x]!='.'&&vis[i][x]!=id)
			{
				vis[i][x]=id;
				return 1+solve(i,x);
			}
		}
	}
	return 1;
}
int main(){
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	CS;
	cin>>n>>m;
	arr.resize (n+5,vector<char>(m+5));
	vis.resize (n+5,vector<int>(m+5));
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>arr[i][j],vis[i][j]=0;
	int ans[n][m]={0};
	int mx=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			vis[i][j]=id,ans[i][j]=solve(i,j),id++,mx=max(mx,ans[i][j]);
	int cnt=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(ans[i][j]==mx)
				cnt++;
	cout<<mx<<' '<<cnt;
	return 0;
}
//ll kk = ((x%mod)*(fastpow (i,mod-2))%mod)%mod;