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/env python2
# -*- coding: utf-8 -*-
import sys
input = sys.stdin
output = sys.stdout

EMPTY = 0
UP = 1
DOWN = 2
LEFT = 3
RIGHT = 4

TYPES = {'.':EMPTY, 'U':UP, 'D':DOWN, 'L':LEFT, 'R':RIGHT}
MARKS = {EMPTY:'.', UP:'U', DOWN:'D', LEFT:'L', RIGHT:'R'}

class Cell:
    
    def __init__(self, type):
        assert type in TYPES.values()
        self.type = type
        self.points = 1
        self.visited = False
    
    def __repr__(self):
        return str((MARKS[self.type],self.points,self.visited))

def solve(size,field):

    #print field

    n,m = size

    cell = lambda field,pos: field[pos[0]][pos[1]]
    
    def next_pos(p,field):
        i,j = p
        t = cell(field,p).type
        #print MARKS[t]
        if t == UP:
            for r in range(i-1,-1,-1):
                e = cell(field,(r,j))
                if not e.visited and e.type != EMPTY:
                    return (r,j)
        elif t == DOWN:
            for r in range(i+1,n):
                e = cell(field,(r,j))
                if not e.visited and e.type != EMPTY:
                    return (r,j)
        elif t == LEFT:
            for c in range(j-1,-1,-1):
                e = cell(field,(i,c))
                if not e.visited and e.type != EMPTY:
                    return (i,c)
        elif t == RIGHT:
            for c in range(j+1,m):
                e = cell(field,(i,c))
                if not e.visited and e.type != EMPTY:
                    return (i,c)
        else:
            return None
    
    def trace_path_from(beg,field):
        # finding path
        path = []
        pos = beg
        while pos:
            path.append(pos)
            c = cell(field,pos)
#            if c.visited:
#                break
            c.visited = True
            pos = next_pos(pos,field)
        # clear visited marks
        for p in path:
            cell(field,p).visited = False
        return len(path)
    
    PL = {}
    for r in range(n):
        for c in range(m):
            p = (r,c)
            l = trace_path_from(p, field)
            if l not in PL:
                PL[l] = 1
            else:
                PL[l] += 1

    M = max(PL.keys())
    return (M, PL[M])

S = input.readline().split(' ')
n = int(S[0])
m = int(S[1])
assert 1<=n and 1<=m and n*m <= 5000

field = []
for r in range(n):
    line = input.readline().strip()
    assert len(line) == m
    row = list(map(lambda c: Cell(TYPES[c]), line))
    field.append(row)

points,moves = solve((n,m),field)

output.write('%s %s\n' % (points,moves))
