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.InputMismatchException;
import java.math.BigInteger;
import java.io.*;
import java.util.HashSet;
import java.util.Arrays;
import java.util.HashMap;

/**
 * Generated by Contest helper plug-in
 * Actual solution is at the bottom
 */
public class Main {
    public static void main(String[] args) {
        InputReader in = new StreamInputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        run(in, out);
    }

    public static void run(InputReader in, PrintWriter out) {
        Solver solver = new taskC();
        solver.solve(1, in, out);
        Exit.exit(in, out);
    }
}

abstract class InputReader {
    private boolean finished = false;

    public abstract int read();

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

    public String readString(){
        return nextToken();
    }
    public String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public void setFinished(boolean finished) {
        this.finished = finished;
    }

    public abstract void close();
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar, numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    @Override
    public void close() {
        try {
            stream.close();
        } catch (IOException ignored) {
        }
    }
}

class Exit {
    private Exit() {
    }

    public static void exit(InputReader in, PrintWriter out) {
        in.setFinished(true);
        in.close();
        out.close();
    }
}

interface Solver {
    public void solve(int testNumber, InputReader in, PrintWriter out);
}

class taskC implements Solver {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        char[][] s = new char[n][];
        for (int i = 0; i < n; ++i) {
            s[i] = in.nextToken().toCharArray();
        }
        int next[][][][] = new int[n][m][4][2];
        int parent[][][][] = new int[n][m][4][2];
        int nextWork[][][][] = new int[n][m][4][2];
        int parentWork[][][][] = new int[n][m][4][2];
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j)
                for (int d = 0; d < 4; ++d)       {
                    nextWork[i][j][d] = new int[] {-1, -1};
                    parentWork[i][j][d] = new int[] {-1, -1};
                }

        int cnt = -1, mx  = -1;

        HashMap<Character, Integer > difi = new HashMap<Character, Integer>();
        HashMap<Character, Integer > difj = new HashMap<Character, Integer>();
        difi.put('L', 0);difi.put('R', 0);difi.put('U', -1);difi.put('D', +1);
        difj.put('L', -1);difj.put('R', +1);difj.put('U', 0);difj.put('D', 0);
        int dj[] = new int[] {-1, +1, 0, 0};
        int di[] = new int[] {0, 0, -1, +1};
        // LRUD

        for (int i =0; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                if (!difi.containsKey(s[i][j]))continue;
                for (int dir = 0; dir < 4; ++dir) {
                    int ci = i, cj = j;
                    ci += di[dir];
                    cj += dj[dir];
                    while (true) {
                        if (ci < 0 || cj < 0 || ci >= n || cj >= m) {
                            next[i][j][dir][0] = -1;
                            break;
                        }
                        if (s[ci][cj] == '.') {
                            ci += di[dir];
                            cj += dj[dir];
                        } else {
                            next[i][j][dir] = new int[]{cj, ci};
                            parent[ci][cj][dir] = new int[]{j ,i};
                            break;
                        }
                    }
                }
            }
        for (int i =0 ; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                if (!difi.containsKey(s[i][j]))continue;
                for (int u = 0; u < n; ++u)
                    for (int v = 0; v < m; ++v) {
                        for (int dir = 0; dir < 4; ++dir) {
                            if (next[u][v][dir][0] == -1){
                                nextWork[u][v][dir][0] = -1;
                            } else {
                                nextWork[u][v][dir][0] = next[u][v][dir][0];
                                nextWork[u][v][dir][1] = next[u][v][dir][1];
                            }
                            if (parent[u][v][dir][0] == -1) {
                                parentWork[u][v][dir][0] = -1;
                            } else {
                                parentWork[u][v][dir][0] = parent[u][v][dir][0];
                                parentWork[u][v][dir][1] = parent[u][v][dir][1];
                            }
                        }
                    }
                int ci = i, cj = j, ddi = difi.get(s[i][j]), ddj = difj.get(s[i][j]);
                int cur = 1 ;
                while (true) {
                    int d = getDir(s[ci][cj]);
                    if (nextWork[ci][cj][d][0] == -1) break;
                    for (int ndir = 0; ndir < 4; ++ndir) {
                        if (parentWork[ci][cj][ndir][0] != -1) {
                            int pi = parentWork[ci][cj][ndir][1];
                            int pj = parentWork[ci][cj][ndir][0];
                            if (nextWork[ci][cj][ndir][0] == -1) {
                                nextWork[pi][pj][ndir][0] = -1;
                            } else {
                                nextWork[pi][pj][ndir][0] = nextWork[ci][cj][ndir][0];
                                nextWork[pi][pj][ndir][1] = nextWork[ci][cj][ndir][1];
                                parentWork[nextWork[ci][cj][ndir][1]][nextWork[ci][cj][ndir][0]][ndir][0] = pj;
                                parentWork[nextWork[ci][cj][ndir][1]][nextWork[ci][cj][ndir][0]][ndir][1] = pi;
                            }
                        }
                    }
                    int tti = nextWork[ci][cj][d][1];
                    int ttj = nextWork[ci][cj][d][0];
                    ci = tti;
                    cj = ttj;
                    ++ cur;
                }
                if (cur == mx) ++ cnt;
                else if (cur > mx) {
                    cnt = 1;
                    mx = cur;
                }
            }
        out.print(mx + " " + cnt);
    }
    int getDir(char x) {
        if (x == 'L')return 0;
        if (x == 'R')return 1;
        if (x == 'U') return 2;
        return 3;
    }
    }
