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

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>

using namespace std;

char mm[10000];
int next[10000][4];
int tn[10000][4];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
int N,M;
#define mat(i,j) (mm[(i)*M+(j)])
#define no(i,j) ((i)*M+(j))
bool isin(int x,int y){
    return x>=0&&x<N&&y>=0&&y<M;
}
int findj(int j,int dir){

    if (j==-1||tn[j][dir]==j) return j;
    else return tn[j][dir] = findj(tn[j][dir],dir);

}
char str[10000];
int main(){
    int i,j,k,sx,sy,x,y;
    while(scanf("%d%d",&N,&M)!=EOF){
        int T = 0;
        for (i=0;i<N;i++){
            scanf("%s",str);
            for (j=0;j<M;j++)
                mm[T++] = str[j];
        }

        for (i=0;i<N;i++)
            for (j=0;j<M;j++)
                for (k=0;k<4;k++){
                    next[no(i,j)][k]=no(i,j);
                    if (mat(i,j)=='.') {
                        if (isin(i+dx[k],j+dy[k]))
                            next[no(i,j)][k] = no(i+dx[k],j+dy[k]);
                        else next[no(i,j)][k] = -1;
                    }
                }
        int Max = 0,num;
        for (sx = 0;sx<N;sx++)
            for (sy=0;sy<M;sy++){
                for (i=0;i<N;i++)
                    for (j=0;j<M;j++)
                        for (k=0;k<4;k++)
                            tn[no(i,j)][k] = next[no(i,j)][k];
                x = sx,y = sy;
                if (mat(x,y)=='.') continue;
                int cnt = 1;
                //printf("%d %d-------------------\n",x,y);
                while(1){
                    //printf("%d %d\n",x,y);
                    j = no(x,y);
                    for (k=0;k<4;k++)
                        if (isin(x+dx[k],y+dy[k]))
                            tn[no(x,y)][k] = no(x+dx[k],y+dy[k]);
                        else tn[no(x,y)][k] = -1;
                    for (k=0;k<4;k++)
                    {
                        int nx = x+dx[k],ny = y+dy[k];
                        if (isin(nx,ny))
                            tn[no(nx,ny)][(k+2)%4]=tn[no(x,y)][(k+2)%4];
                    }
                    if (mat(x,y)=='U')
                        j = findj(j,0);
                    else if (mat(x,y)=='D') 
                        j = findj(j,2);
                    else if (mat(x,y)=='L')
                        j = findj(j,3);
                    else if (mat(x,y)=='R')
                        j = findj(j,1);
                    if (j==-1) break;
                    
                    x = j/M,y = j%M;
                    cnt++;
                }
                if (cnt>Max){
                    Max=cnt;
                    num = 1;
                }else if (cnt==Max){
                    num++;
                }
            }
        printf("%d %d\n",Max,num);
    }
}
                    
                        
                        
                    
        
        

			    	  						 	 	  	