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.util.Scanner;

public class E {
    
    private static char[][] grid;
    private static int      maxScore = 0;
    private static int      maxNum   = 0;
    private static char[][] gridCopy;
    private static char[][] gridDone;
    
    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];
        for (int i = 0; i < N; i++) {
            String t = sc.next();
            for (int j = 0; j < M; j++) {
                grid[i][j] = t.charAt(j);
            }
        }
        
        gridDone = new char[N][M];
        
        gridCopy = new char[N][M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                gridCopy[i][j] = new Character(grid[i][j]);
            }
        }
        
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                char t = grid[i][j];
                if (t == '.' || gridDone[i][j] == '.')
                    continue;
                
                gridDone[i][j] = '.';
                int score = doThing(t, i, j, 0, N, M);
                if (score > maxScore) {
                    maxScore = score;
                    maxNum = 1;
                } else if (score == maxScore) {
                    maxNum++;
                }
                
                gridCopy = new char[N][M];
                for (int k = 0; k < N; k++) {
                    for (int l = 0; l < M; l++) {
                        gridCopy[k][l] = new Character(grid[k][l]);
                    }
                }
                
            }
        }
        
        System.out.println(maxScore + " " + maxNum);
    }
    
    private static int doThing(char t, int i, int j, int sc, int N, int M) {
        if (t == 'D') {
            gridCopy[i][j] = '.';
            gridDone[i][j] = '.';
            i++;
            if (i >= N) {
                return sc + 1;
            }
            while (gridCopy[i][j] == '.') {
                i++;
                if (i >= N) {
                    return sc + 1;
                }
            }
            return doThing(gridCopy[i][j], i, j, sc + 1, N, M);
        } else if (t == 'U') {
            gridCopy[i][j] = '.';
            gridDone[i][j] = '.';
            i--;
            if (i < 0) {
                return sc + 1;
            }
            while (gridCopy[i][j] == '.') {
                i--;
                if (i < 0) {
                    return sc + 1;
                }
            }
            return doThing(gridCopy[i][j], i, j, sc + 1, N, M);
        } else if (t == 'R') {
            gridCopy[i][j] = '.';
            gridDone[i][j] = '.';
            j++;
            if (j >= M) {
                return sc + 1;
            }
            while (gridCopy[i][j] == '.') {
                j++;
                if (j >= M) {
                    return sc + 1;
                }
            }
            return doThing(gridCopy[i][j], i, j, sc + 1, N, M);
        } else if (t == 'L') {
            gridCopy[i][j] = '.';
            gridDone[i][j] = '.';
            j--;
            if (j < 0) {
                return sc + 1;
            }
            while (gridCopy[i][j] == '.') {
                j--;
                if (j < 0) {
                    return sc + 1;
                }
            }
            return doThing(gridCopy[i][j], i, j, sc + 1, N, M);
        } else {
            return sc;
        }
    }
    
}