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

//package round74;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class C {
	Scanner in;
	PrintWriter out;
	String INPUT = "3 5\r\n" +
			".D...\r\n" +
			"RRRLL\r\n" +
			".U...";
	
	void solve()
	{
		int n = ni();
		int m = ni();
		char[][] b = new char[n][m];
		for(int i = 0;i < n;i++){
			b[i] = in.next().toCharArray();
		}
		int[] dr = {0,0,-1,1};
		int[] dc = {-1,1,0,0};
		int[][][][] dir = new int[n][m][4][2];
		for(int k = 0;k < n;k++){
			for(int l = 0;l < m;l++){
				for(int u = 0;u < 4;u++){
					for(int v = 0;v < 2;v++){
						dir[k][l][u][v] = -1;
					}
				}
			}
		}
		
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				if(b[i][j] != '.'){
					for(int k = 0;k < 4;k++){
						int nr = i+dr[k];
						int nc = j+dc[k];
						while(nr >= 0 && nr < n && nc >= 0 && nc < m && b[nr][nc] == '.'){
							nr += dr[k];
							nc += dc[k];
						}
						
						if(nr >= 0 && nr < n && nc >= 0 && nc < m){
							dir[i][j][k][0] = nr;
							dir[i][j][k][1] = nc;
						}
					}
				}
			}
		}
		
		int[][][][] di = new int[n][m][4][2];
		int max = 0;
		int maxct = 0;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				if(b[i][j] != '.'){
					for(int k = 0;k < n;k++){
						for(int l = 0;l < m;l++){
							for(int u = 0;u < 4;u++){
								for(int v = 0;v < 2;v++){
									di[k][l][u][v] = dir[k][l][u][v];
								}
							}
						}
					}
					
					int t;
					int r = i;
					int c = j;
					for(t = 0;r != -1;t++){
						int[] L = di[r][c][0];
						int[] R = di[r][c][1];
						int[] U = di[r][c][2];
						int[] D = di[r][c][3];
						if(L[0] != -1){
							di[L[0]][L[1]][1][0] = R[0];
							di[L[0]][L[1]][1][1] = R[1];
						}
						if(R[0] != -1){
							di[R[0]][R[1]][0][0] = L[0];
							di[R[0]][R[1]][0][1] = L[1];
						}
						if(U[0] != -1){
							di[U[0]][U[1]][3][0] = D[0];
							di[U[0]][U[1]][3][1] = D[1];
						}
						if(D[0] != -1){
							di[D[0]][D[1]][2][0] = U[0];
							di[D[0]][D[1]][2][1] = U[1];
						}
						
						int[] next;
						if(b[r][c] == 'L'){
							next = L;
						}else if(b[r][c] == 'R'){
							next = R;
						}else if(b[r][c] == 'U'){
							next = U;
						}else if(b[r][c] == 'D'){
							next = D;
						}else{
							next = null;
						}
						r = next[0];
						c = next[1];
					}
					if(t > max){
						max = t;
						maxct = 0;
					}
					if(t == max){
						maxct++;
					}
				}
			}
		}
		out.println(max + " " + maxct);
	}
	
	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception
	{
		new C().run();
	}
	
	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
