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<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<stack>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long LL;
typedef short int ST;
int n, m;
char maze[5100][5100];
ST  ly[5050], ry[5050], ux[5050], dx[5050];
ST  LY[5050], RY[5050], UX[5050], DX[5050];
int sw[200];
int ans, kind;
inline int ind(int x, int y) {
	return x * m + y;
}
void getl() {
	for(int i = 0; i < n; i++) {
		ly[ind(i, 0)] = -1;
		for(int j = 1; j < m; j++) {
			if(maze[i][j - 1] != '.') {
				ly[ind(i,j)] = j - 1;
			} else {
				ly[ind(i,j)] = ly[ind(i,j - 1)];
			}
		}
	}
}
void getr() {
	for(int i = 0; i < n; i++) {
		ry[ind(i, m - 1)] = -1;
		for(int j = m - 2; j >= 0; j--) {
			if(maze[i][j + 1] != '.') {
				ry[ind(i, j)] = j + 1;
			} else {
				ry[ind(i,j)] = ry[ind(i,j + 1)];
			}
		}
	}
}
void getu() {
	for(int j = 0; j < m; j++) {
		ux[ind(0,j)] = -1;
		for(int i = 1; i < n; i++) {
			if(maze[i - 1][j] != '.') {
				ux[ind(i,j)] = i - 1;
			} else {
				ux[ind(i,j)] = ux[(i - 1, j)];
			}
		}
	}
}
void getd() {
	for(int j = 0; j < m; j++) {
		dx[ind(n - 1,j)] = -1;
		for(int i = n - 2; i >= 0; i--) {
			if(maze[i + 1][j] != '.') {
				dx[ind(i,j)] = i + 1;
			} else {
				dx[ind(i,j)] = dx[ind(i + 1,j)];
			}
		}
	}
}
bool hash[5005][5005];
void init() {
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			LY[ind(i,j)] = ly[ind(i,j)];
			RY[ind(i,j)] = ry[ind(i,j)];
			UX[ind(i,j)] = ux[ind(i,j)];
			DX[ind(i,j)] = dx[ind(i,j)];
			if(maze[i][j] == '.') hash[i][j] = false;
			else hash[i][j] = true;
		}
	}
}
void update(int X, int Y) {
	if(LY[ind(X,Y)] != -1) {
		RY[ind(X, LY[ind(X,Y)])] = RY[ind(X,Y)];
	}
	if(RY[ind(X,Y)] != -1) {
		LY[ind(X,RY[ind(X,Y)])] = LY[ind(X,Y)];
	}
	if(UX[ind(X,Y)] != -1) {
		DX[ind(UX[ind(X,Y)],Y)] = DX[ind(X,Y)];
	}
	if(DX[ind(X,Y)] != -1) {
		UX[ind(DX[ind(X,Y)],Y)] = UX[ind(X,Y)];
	}
}
/*
4 4
DRLD
U.UL
.UUR
RDDL
*/
void gao(int sx, int sy) {
	int cnt = 0;
//	cout<<"~~~"<<endl;
	while(sx != -1 && sy != -1) {
		//cout<<sx<<" "<<sy<<endl;
	//	system("PAUSE");
		cnt += hash[sx][sy];
		hash[sx][sy] = false;
		int tx = sx, ty = sy;
		if(maze[sx][sy] == 'U') {
			tx = UX[ind(sx,sy)];
		} else if(maze[sx][sy] == 'D') {
			tx = DX[ind(sx,sy)];
		} else if(maze[sx][sy] == 'L') {
			ty = LY[ind(sx,sy)];
		} else if(maze[sx][sy] == 'R') {
			ty = RY[ind(sx,sy)];
		}
		update(sx, sy);
		sx = tx, sy = ty;
	}
	if(cnt > ans) {
		ans = cnt;
		kind = 1;
	} else {
		if(cnt == ans) {
			kind ++;
		}
	}
}
int main() {
	sw['L'] = 3;
	sw['R'] = 2;
	sw['D'] = 0;
	sw['U'] = 1;
	while(~scanf("%d%d", &n, &m)) {
		for(int i = 0; i < n; i++) scanf("%s", maze[i]);
		getl();
		getr();
		getu();
		getd();
		ans = -1;
		kind = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(maze[i][j] == '.') continue;
				init();
				gao(i, j);
			}
		}
		printf("%d %d\n", ans, kind);
	}
	return 0;
}
   									 		 	  	   			