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 <fstream>
#include <string>
#include <set>
#include <map>
#include <sstream>
#include <ctime>
#include <hash_map>
#include <memory.h>
#include <queue>
#include <list>

using namespace std;
using namespace stdext;

#ifdef ONLINE_JUDGE
#include <iostream>
#else
ifstream cin("input.txt");
ofstream cout("output.txt");
#endif

const int sz = 5000;

struct fenwick
{
	int n;
	short a[sz];
	void setN(int nn)
	{
		n = nn;
	}
	void operator = (fenwick &f)
	{
		n = f.n;
		memcpy(a,f.a,n*2);
	}
	int sum(int i)
	{
		int res = 0;
		for(; i >= 0; i = (i&(i+1))-1)
			res += a[i];
		return res;
	}

	int sum(int i, int j)
	{
		return sum(j)-sum(i-1);
	}

	void inc(int i, int d)
	{
		for(; i < n; i |= i+1)
			a[i] += d;
	}
};

int n, m;

char a[sz][sz],data[sz][sz];
fenwick dcol[sz], drow[sz], col[sz], row[sz];
int ma = 0, cnt = 0;

int calc(int x, int y)
{
	for(int i = 0; i < n; i++)
		memcpy(a[i],data[i],m);
	for(int i = 0; i < n; i++)
		row[i] = drow[i];
	for(int i = 0; i < m; i++)
		col[i] = dcol[i];
	int ans = 0;
	while(true)
	{
		ans++;
		char buf = a[x][y];
		a[x][y] = '.';
		row[x].inc(y,-1);
		col[y].inc(x,-1);

		int L = 1<<13, res = 0;

		if(buf == 'R')
		{
			int sumR = row[x].sum(y,m-1);
			if(sumR == 0)
				return ans;
			while(L)
			{
				int test = res|L;
				if(test < m && row[x].sum(test,m-1) >= sumR)
					res = test;
				L >>= 1;
			}
			y = res;
		}
		else if(buf == 'L')
		{
			int sumL = row[x].sum(0,y);
			if(sumL == 0)
				return ans;
			while(L)
			{
				int test = res|L;
				if(test < m && row[x].sum(0,test-1) < sumL)
					res = test;
				L >>= 1;
			}
			y = res;
		}
		else if(buf == 'U')
		{
			int sumU = col[y].sum(0,x);
			if(sumU == 0)
				return ans;
			while(L)
			{
				int test = res|L;
				if(test < n && col[y].sum(0,test-1) < sumU)
					res = test;
				L >>= 1;
			}
			x = res;
		}
		else if(buf == 'D')
		{
			int sumD = col[y].sum(x,n-1);
			if(sumD == 0)
				return ans;
			while(L)
			{
				int test = res|L;
				if(test < n && col[y].sum(test,n-1) >= sumD)
					res = test;
				L >>= 1;
			}
			x = res;
		}
	}
}

__int32 main()
{
	/*cout << "1 5000\n";
	for(int i = 0; i < 2500; i++)
		cout << "R";
	for(int i = 0; i < 2500; i++)
		cout << "L";
	return 0;/**/
	cin >> n >> m;
	for(int i = 0; i< n; i++)
		row[i].setN(m);
	for(int i = 0; i< m; i++)
		col[i].setN(n);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> data[i][j];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(data[i][j] != '.')
			{
				drow[i].inc(j,1);
				dcol[j].inc(i,1);
			}
	//cout << drow[0].sum(3,3) << endl;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(data[i][j] != '.')
			{
				int test = calc(i,j);

				if(test > ma)
				{
					ma = test;
					cnt = 1;
				}
				else if(test == ma)
					cnt++;
			}
	cout << ma << ' ' << cnt;
}
