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.util.Arrays;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;

public class C {
    public void run() throws IOException {
        int[] dr = {0, 0, 1, -1};
        int[] dc = {1, -1, 0, 0};

        int n = nextInt();
        int m = nextInt();

        int[][] dir = new int[n][m];

        for (int i = 0; i < n; ++i) {
            char[] row = nextToken().toCharArray();
            for (int j = 0; j < m; ++j) {
                if (row[j] == 'L') {
                    dir[i][j] = 1;
                }
                else if (row[j] == 'R') {
                    dir[i][j] = 0;
                }
                else if (row[j] == 'U') {
                    dir[i][j] = 3;
                }
                else if (row[j] == 'D') {
                    dir[i][j] = 2;
                }
                else {
                    dir[i][j] = -1;
                }
            }
        }

        int[][][] nextr = new int[n][m][4];
        int[][][] nextc = new int[n][m][4];

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                for (int d = 0; d < 4; ++d) {
                    nextr[i][j][d] = -1;
                    nextc[i][j][d] = -1;
                    int r = i + dr[d];
                    int c = j + dc[d];
                    while (r >= 0 && r < n && c >= 0 && c < m) {
                        if (dir[r][c] != -1) {
                            nextr[i][j][d] = r;
                            nextc[i][j][d] = c;
                            break;
                        }
                        r += dr[d];
                        c += dc[d];
                    }
                }
            }
        }

        int[][][] nr = new int[n][m][4];
        int[][][] nc = new int[n][m][4];

        int ans = 0;
        int ansCount = 0;

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (dir[i][j] != -1) {
                    for (int k = 0; k < n; ++k) {
                        for (int l = 0; l < m; ++l) {
                            for (int d = 0; d < 4; ++d) {
                                nr[k][l][d] = nextr[k][l][d];
                                nc[k][l][d] = nextc[k][l][d];
                            }
                        }
                    }

                    int r = i;
                    int c = j;

                    int count = 0;

                    while (r >= 0 && r < n && c >= 0 && c < m) {
                        ++count;
                        for (int d = 0; d < 4; ++d) {
                            if (nr[r][c][d] != -1 && nc[r][c][d] != -1) {
                                nr[nr[r][c][d]][nc[r][c][d]][d^1] = nr[r][c][d^1];
                                nc[nr[r][c][d]][nc[r][c][d]][d^1] = nc[r][c][d^1];
                            }
                        }

                        int d = dir[r][c];
                        if (d == -1) {
                            break;
                        }
                        int r2 = nr[r][c][d];
                        int c2 = nc[r][c][d];
                        r = r2;
                        c = c2;
                    }

                    if (count > ans) {
                        ans = count;
                        ansCount = 1;
                    }
                    else if (count == ans) {
                        ++ansCount;
                    }
                }
            }
        }

        out.println(ans + " " + ansCount);
    }

    public static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static final PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);

        new C().run();

        out.close();
    }

    public static StringTokenizer tokenizer;

    public static String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}
