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 <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lowbit(x) (x&(-x))
#define LL long long
#define ULL unsigned long long
#define maxn 5005
#define msize 2001
#define mod 1000000009ll
#define CC(m,what) memset(m,what,sizeof(m))
#define inf 0x7f7f7f7f
#define eps 1e-12
#define lson l , mid , fa << 1
#define rson mid + 1 , r , fa << 1 | 1
#define pi acos(-1.0)
#define keytree (ch[ch[root][1]][0])

template<class Z>inline bool checkmax(Z &a,Z b){if(a==-1||a<b){a=b;return true;}return false;}
template<class Z>inline bool checkmin(Z &a,Z b){if(a==-1||a>b){a=b;return true;}return false;}

char str[maxn];
char ss[maxn];
bool hash[maxn];
int n,m;
int go[4][2]={-1,0, 1,0, 0,-1, 0,1};
//              U    D    L     R
int dir[130];
int ans,cnt;
set< vector<int> > hh;
void init() {
	ans=-inf;
	str[0]=0;
	hh.clear();
}

void run(int si,int sj,int s) {
	
	vector<int>p;
	int cc=1;
	CC(hash,0);
	//printf("(%d,%d)",si,sj);
	int d=dir[str[s]];
	while(1) {
		
		si+=go[d][0];
		sj+=go[d][1];
		s=si*m+sj;
		if(si<0 || sj<0 || si>=n || sj>=m) break;
	 	if(str[s]=='.' || hash[s]) continue;
	 	p.push_back(s);
	 	//printf("-->(%d,%d)",si,sj);
		d=dir[str[s]];
		cc++;
		
		hash[s]=1;
		
	}
	
	//printf("cc=%d\n",cc);
	//sort(p.begin(),p.end());
	if(hh.find(p)==hh.end()) {
		hh.insert(p);
		
		if(cc==ans) {
			cnt++;
		}
		else if(cc>ans) {
			ans=cc;
			cnt=1;
		}	
	}
	
}

int main() {
	dir['U']=0; dir['D']=1; dir['L']=2; dir['R']=3;
	while(~scanf("%d%d",&n,&m)) {
		init();
		for(int i=0;i<n;i++) {
			scanf("%s",ss);
			strcat(str,ss);
		}
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				int x=i*m+j;
				if(str[x]!='.') {
					run(i,j,x);
				}
			}
		}
		cout<<ans<<' '<<cnt<<endl;
	}	
}

		 	 				  	   		   		 	 	