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 <bits/stdc++.h>
#include <fstream>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N=1e7+5;
int mod=1e9+7;
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
int n=0,m=0;
string arr[5005];
bool vist[5005][5005]={};
int check(int x, int y)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            vist[i][j]=0;
    }
    int co=0;
    while(true)
    {
        vist[x][y]=1;
        co++;
            bool done=0;
        if(arr[x][y]=='R')
        {
            for(int j=y+1;j<m;j++)
            {
                if(!vist[x][j]&&arr[x][j]!='.')
                {
                    done=1;
                    y=j;
                    break;
                }

            }

        }
        else if(arr[x][y]=='L')
        {
            for(int j=y-1;j>=0;j--)
            {
                if(!vist[x][j]&&arr[x][j]!='.')
                {
                    done=1;
                    y=j;
                    break;
                }

            }
        }
        else if(arr[x][y]=='U')
        {
            for(int j=x-1;j>=0;j--)
            {
                if(!vist[j][y]&&arr[j][y]!='.')
                {
                    done=1;
                    x=j;
                    break;
                }

            }


        }
        else if(arr[x][y]=='D')
        {
            for(int j=x+1;j<n;j++)
            {
                if(!vist[j][y]&&arr[j][y]!='.')
                {
                    done=1;
                    x=j;
                    break;
                }

            }


        }
        if(!done)
            return co;

    }

}


int main()
{
    FIO
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll ans=0,co=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int x=check(i,j);
            if(x>ans)
            {
                ans=x;
                co=1;
            }
            else if(x==ans)
                co++;


        }


    }

    cout<<ans<<" "<<co;
return 0;
}
