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.awt.Point;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class _89C_ChipPlay {

	private static char[][] grid;
	private static boolean[][] done;
	private static int maxScore = 0;
	private static int maxNum = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		grid = new char[N][M];
		done = new boolean[N][M];
		for (int i = 0; i < N; i++) {
			grid[i] = sc.next().toCharArray();
		}

		Point t = null;
		while ((t = hasNext()) != null) {
			done[t.x][t.y] = true;
			if (grid[t.x][t.y] == '.')
				continue;
			int num = solve(t.x, t.y);
			map.put(new Point(t.x, t.y), num);
			//System.out.println(t.x+":"+t.y+" = "+num);
			if (num > maxScore) {
				maxScore = num;
				maxNum = 1;
			} else if (num == maxScore) {
				maxNum++;
			}
		}

		System.out.println(maxScore + " " + maxNum);

	}

	private static HashMap<Point, Integer> map = new HashMap<Point, Integer>();

	private static int solve(int x, int y) {
		int ans = 1;
		char t = grid[x][y];
		grid[x][y] = '.';
		int tmp;
		switch (t) {
			case 'D':
				tmp = x;
				while (tmp < grid.length) {
					if (grid[tmp][y] != '.') {
						if (map.containsKey(new Point(tmp, y)) && !(t == opposite(grid[tmp][y]))) {
							ans += map.get(new Point(tmp, y));
						} else {
							ans += solve(tmp, y);
						}
						break;
					}
					tmp++;
				}
				break;
			case 'U':
				tmp = x;
				while (tmp >= 0) {
					if (grid[tmp][y] != '.') {
						if (map.containsKey(new Point(tmp, y)) && !(t == opposite(grid[tmp][y]))) {
							ans += map.get(new Point(tmp, y));
						} else {
							ans += solve(tmp, y);
						}
						break;
					}
					tmp--;
				}
				break;
			case 'L':
				tmp = y;
				while (tmp >= 0) {
					if (grid[x][tmp] != '.') {
						if (map.containsKey(new Point(x, tmp)) && !(t == opposite(grid[x][tmp]))) {
							ans += map.get(new Point(x, tmp));
						} else {
							ans += solve(x, tmp);
						}
						break;
					}
					tmp--;
				}
				break;
			case 'R':
				tmp = y;
				while (tmp < grid[0].length) {
					if (grid[x][tmp] != '.') {
						if (map.containsKey(new Point(x, tmp)) && !(t == opposite(grid[x][tmp]))) {
							ans += map.get(new Point(x, tmp));
						} else {
							ans += solve(x, tmp);
						}
						break;
					}
					tmp++;
				}
				break;
		}
		grid[x][y] = t;
		return ans;
	}

	private static char opposite(char t) {
		switch (t) {
			case 'D':
				return 'U';
			case 'U':
				return 'D';
			case 'L':
				return 'R';
			case 'R':
				return 'L';
		}
		return '\u0000';
	}

	private static Point hasNext() {
		for (int i = 0; i < grid.length; i++) {
			for (int j = 0; j < grid[0].length; j++) {
				if (!done[i][j])
					return new Point(i, j);
			}
		}
		return null;
	}
}
