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.*;


public class Main {

    public static void main(String[] args) {
        class E implements Runnable {
            public int next[][][];
            public String line[];
            public int last[][][];
            int maxDepth,cnt;
            int n,m;
            public void read() {
                
            }
            @Override
            public void run() {
                Scanner scanner = new Scanner(System.in);
                n = scanner.nextInt();
                m = scanner.nextInt();
                line = new String[n];
                next = new int[n][m][4];
                last = new int[n][m][4];
                int pre[] = new int[m];
                int tmp;
                Arrays.fill(pre, -1);
                for (int i = 0; i < n; i ++) {
                    tmp = -1;
                    line[i] = scanner.next();
                    for (int j = 0;j < m; j ++) {
                        if (line[i].charAt(j) != '.') {
                            next[i][j][0] = pre[j];
                            next[i][j][2] = tmp;
                            tmp = j;
                            pre[j] = i;
                        }
                    }
                }
                Arrays.fill(pre, n);
                for (int i = n-1; i >= 0; i --) {
                    tmp = m;
                    for (int j = m - 1; j >= 0; j --) {
                        if (line[i].charAt(j) != '.' ) {
                            next[i][j][1] = pre[j];
                            next[i][j][3] = tmp;
                            tmp = j;
                            pre[j] = i;
                        }
                    }
                }
                maxDepth = 0;
                cnt = 1;
                for (int i = 0; i < n; i ++) {
                    for (int j = 0; j < m;j ++) {
                        if (line[i].charAt(j) != '.') {
                            dfs(i, j, 1);
                        }
                    }
                }
                System.out.println(maxDepth + " " + cnt);
            }
            
            public void dfs(int x,int y,int deep) {
                if (x < 0 || x >= n || y < 0 || y >= m) return;
                if (deep > 10) return;
                if (deep > maxDepth) {
                    maxDepth = deep ;
                    cnt = 1;
                } else if (deep == maxDepth) {
                    cnt ++;
                }
                int pos[] = new int[4];
                if (next[x][y][2] >= 0 && next[x][y][2] < m) {
                    pos[3] = next[x][next[x][y][2]][3];
                    next[x][next[x][y][2]][3] = next[x][y][3];
                }
                if (next[x][y][3] >= 0 && next[x][y][3] < m) {
                    pos[2] = next[x][next[x][y][3]][2] ;
                    next[x][next[x][y][3]][2] = next[x][y][2];
                }
                if ( next[x][y][0] >= 0 && next[x][y][0] < n) {
                    pos[1] = next[next[x][y][0]][y][1];
                    next[next[x][y][0]][y][1] = next[x][y][1];
                }
                if (next[x][y][1] >= 0 && next[x][y][1] < n) {
                    pos[0] = next[next[x][y][1]][y][0];
                    next[next[x][y][1]][y][0] = next[x][y][0];
                }
                
                if (line[x].charAt(y) == 'U' ) {
                    dfs(next[x][y][0], y, deep + 1);
                } else if (line[x].charAt(y) == 'D') {
                    dfs(next[x][y][1], y, deep + 1);
                } else if(line[x].charAt(y) == 'L') {
                    dfs(x, next[x][y][2], deep + 1);
                } else {
                    dfs(x, next[x][y][3], deep + 1);
                }

                if (next[x][y][2] >= 0 && next[x][y][2] < m) {
                    next[x][next[x][y][2]][3] = pos[3];
                }
                if (next[x][y][3] >= 0 && next[x][y][3] < m) {
                    next[x][next[x][y][3]][2] = pos[2];
                }
                if ( next[x][y][0] >= 0 && next[x][y][0] < n) {
                    next[next[x][y][0]][y][1] = pos[1];
                }
                if (next[x][y][1] >= 0 && next[x][y][1] < n) {
                    next[next[x][y][1]][y][0] = pos[0];
                }
                
            }
            
        }
        E e = new E();
        e.run();
    }

}
