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

#!/usr/bin/python

import sys
import math
import copy

result = []
answer = -1

def calc(mat, x, y):
    ans = 0
    if mat[x][y] == -1:
        return 0
    
    path = []
    
    while True:
        path.append((x,y))
        if mat[x][y][1][0] != -1:
            mat[mat[x][y][1][0]][y][1][1] = mat[x][y][1][1]

        if mat[x][y][1][1] != -1:
            mat[mat[x][y][1][1]][y][1][0] = mat[x][y][1][0]

        if mat[x][y][1][2] != -1:
            mat[x][mat[x][y][1][2]][1][3] = mat[x][y][1][3]

        if mat[x][y][1][3] != -1:
            mat[x][mat[x][y][1][3]][1][2] = mat[x][y][1][2]

        ans += 1
        d = mat[x][y][0]
        if mat[x][y][1][d] != -1:
            if d == 0 or d == 1:
                x = mat[x][y][1][d]
            else:
                y = mat[x][y][1][d]
        else:
            break

    path.reverse()
    
    for x,y in path:
        if mat[x][y][1][0] != -1:
            mat[mat[x][y][1][0]][y][1][1] = x

        if mat[x][y][1][1] != -1:
            mat[mat[x][y][1][1]][y][1][0] = x

        if mat[x][y][1][2] != -1:
            mat[x][mat[x][y][1][2]][1][3] = y

        if mat[x][y][1][3] != -1:
            mat[x][mat[x][y][1][3]][1][2] = y

    return ans
if __name__=="__main__":
    
    arrow = {"U":0,"D":1,"L":2,"R":3}

    data = sys.stdin.readlines()
    n,m = [int(v) for v in data[0].split(' ')]

    col = [-1] * m
    mat = [[-1] * m for i in range(0,n)]

    for i in range(0,n):
        row = -1
        for j in range(0,m):
            if data[i+1][j] =='.':
                mat[i][j] = -1
                continue
            
            direction = arrow[data[i+1][j]]
            u = col[j]
            d = -1
            l = row
            r = -1
            mat[i][j] = (direction,[u,d,l,r])

            if u != -1:
                mat[u][j][1][1] = i ## up.down -> here
            if l != -1:
                mat[i][l][1][3] = j ## left.right -> here
            
            row = j
            col[j] = i   # update row && col

    num = 0
    for i in range(0,n):
        for j in range(0,m):
            if j % 100 == 0:
                print j,answer
            rt = calc(mat, i, j)
            if rt > answer:
                answer = rt
                num = 1
            elif rt == answer:
                num += 1

    print answer,num

