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

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;


public class Main {
	public static void main(String[] args) throws FileNotFoundException
	{
		//PrintWriter fout = new PrintWriter(new File("output.txt"));
		//Scanner fin = new Scanner(new File("input.txt"));
		
		int n=in.nextInt(), m=in.nextInt();
		
		char[] ct;
		String tm, nap=".LRUD";
		
		int i,j,k,l;
		int p[][] = new int[n][m];
		
		List<pair> e[][] = (ArrayList<pair>[][]) new ArrayList[n][m];
		
		for(i=0;i<n;++i){
			tm = in.next();
			ct = tm.toCharArray();
			
			for(j=0;j<m;++j){
				p[i][j]=nap.indexOf(ct[j]);
				
				e[i][j] = new ArrayList<pair>();
			}
		}
		
		for(i=0;i<n;++i)
		for(j=0;j<m;++j){
			if(p[i][j]==1){
				for(k=j-1;k>=0;--k) if(p[i][k]>0) e[i][j].add(new pair(i,k));
			}
			if(p[i][j]==2){
				for(k=j+1;k<m;++k) if(p[i][k]>0) e[i][j].add(new pair(i,k));
			}
			if(p[i][j]==3){
				for(k=i-1;k>=0;--k) if(p[k][j]>0) e[i][j].add(new pair(k,j));
			}
			if(p[i][j]==4){
				for(k=i+1;k<n;++k) if(p[k][j]>0) e[i][j].add(new pair(k,j));
			}
		}
		
		boolean u[][] = new boolean[n][m];
		pair[][][] f = new pair[n][m][];
		
		for(i=0;i<n;++i)
		for(j=0;j<m;++j){
			f[i][j] = (pair[])e[i][j].toArray(new pair[0]);
		}
		
		int q[][] = new int[n][m];
		
		int best=0, cnt=0, st=1;
		for(i=0;i<n;++i)
		for(j=0;j<m;++j){
			for(l=0;l<n;++l){
				Arrays.fill(u[l], false);
				Arrays.fill(q[l], 0);
			}
			
			int r=1;
			int x=i,y=j, nx, ny;
			
			u[x][y]=true;
			while(true){
				while( q[x][y]<f[x][y].length && u[ f[x][y][q[x][y]].x ][ f[x][y][q[x][y]].y ] ) ++q[x][y];
			
				if( q[x][y]==f[x][y].length ) break;
				
				nx=f[x][y][q[x][y]].x;
				ny=f[x][y][q[x][y]].y;
				
				u[nx][ny]=true;
				
				++r;
				
				x=nx; y=ny;
				
			}
			
			
			if(r==best) cnt++; else if(best<r){
				best=r; cnt=1;
			}
		}
		
		out.println(best+" "+cnt);
		
		out.flush();
	}
	
	public static class pair{
		public int x, y;
		
		public pair(int p1, int p2){
			x=p1; y=p2;
		}
	}
	
	static PrintWriter out = new PrintWriter(System.out);
	static Scanner in = new Scanner(System.in);
}