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

#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <utility>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forl(i, n) for (int i = 1; i <= int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define ft first
#define sc second
#define X first
#define Y second

using namespace std;

typedef unsigned int uint;
typedef unsigned char byte;
typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;
typedef pair<ld, ld> ptd;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

// 20:10
// 20:34
// 

const int N = 5 * 1000 + 13;

int n, m;
int u = 0, used[N][N];
char a[N][N];

int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, -1, 0, 1 };
char dc[] = { 'U', 'L', 'D', 'R' };
int dir[256];

int l = 0, *last[4][N];
pt *next[4][N];

int calc(int x, int y)
{
    l++;
    u++;
    vector< vector< vector<pt> > > next(4, vector< vector<pt> > (n, vector<pt> (m, mp(-1, -1))));
    
    int ans = 0;
    
    while (true)
    {
        assert(correct(x, y, n, m));
        
        char c = a[x][y];
        assert(c != '.');
        
        ans++;
        used[x][y] = u;
        
        int sx = x, sy = y;
        int dx = ::dx[dir[c]], dy = ::dy[dir[c]];
        int dd = dir[c];
        
        x += dx, y += dy;
        
        while (correct(x, y, n, m))
        {
            if (a[x][y] != '.' && used[x][y] != u)
                break;
                
            if (last[dd][x][y] == l)
            {
                int ox = x, oy = y;
                x = next[dd][ox][oy].ft;
                y = next[dd][ox][oy].sc;
            }
            else
                x += dx, y += dy;
        }
        
        for (int xx = sx, yy = sy; xx != x || yy != y; xx += dx, yy += dy)
        {
            last[dd][xx][yy] = l;
            next[dd][xx][yy] = mp(x, y);
        }
        
        if (!correct(x, y, n, m))
            break;
    }
    
    return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

    forn(i, 4)
        dir[dc[i]] = i;

    cin >> n >> m;
    
    forn(i, 4)
        forn(j, n)
        {
            last[i][j] = new int[m + 1];
            next[i][j] = new pt[m + 1];
        }
    
    forn(i, n)
        scanf("%s", a[i]);
        
    int ansVal = 0, ansCnt = 0;
    
    forn(i, n)
        forn(j, m)
            if (a[i][j] != '.')
            {
                if (clock() > 3600)
                    continue;
                    
                int curVal = calc(i, j);
                
                if (ansVal < curVal)
                {
                    ansVal = curVal;
                    ansCnt = 0;
                }
                
                if (ansVal == curVal)
                    ansCnt++;
            }
            
    cout << ansVal << ' ' << ansCnt << endl;
    
    return 0;
}
