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 <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <tr1/unordered_map>
#include <tr1/unordered_set>

#define umap    tr1::unordered_map
#define uset    tr1::unordered_set
#define pv(i,n) ((i)>0?(i)-1:(n)-1)
#define nx(i,n) ((i)+1<(n)?(i)+1:0)
#define ss(x)   cout<<"DEBUG : "#x" = "<<(x)<<"\n"

using namespace std;

char *g[5000];
int n, m;
int u[5000], d[5000], l[5000], r[5000];
int uu[5000], dd[5000], ll[5000], rr[5000];

inline int pii(int i, int j) {
    return i * n + j;
}

void york() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        g[i] = new char[m + 1];
        cin >> g[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (g[i][j] == '.') continue;
            u[pii(i, j)] = -1;
            d[pii(i, j)] = -1;
            l[pii(i, j)] = -1;
            r[pii(i, j)] = -1;
            for (int k = i - 1; k >= 0; --k) {
                if (g[k][j] != '.') {
                    u[pii(i, j)] = k;
                    break;
                }
            }
            for (int k = i + 1; k < n; ++k) {
                if (g[k][j] != '.') {
                    d[pii(i, j)] = k;
                    break;
                }
            }
            for (int k = j - 1; k >= 0; --k) {
                if (g[i][k] != '.') {
                    l[pii(i, j)] = k;
                    break;
                }
            }
            for (int k = j + 1; k < m; ++k) {
                if (g[i][k] != '.') {
                    r[pii(i, j)] = k;
                    break;
                }
            }
        }
    }
    memcpy(dd, d, sizeof u);
    memcpy(uu, u, sizeof u);
    memcpy(ll, l, sizeof u);
    memcpy(rr, r, sizeof u);

    int cnt = 0;
    int mx = -1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (g[i][j] == '.') continue;
            int x = i;
            int y = j;
            int cur = 0;

            //printf("!!!%d %d\n", i, j);

            int t;
            while (x != -1 && y != -1) {
                ++cur;
                int o = pii(x, y);
                if ((t = ll[o]) != -1) rr[pii(x, t)] = rr[o];
                if ((t = rr[o]) != -1) ll[pii(x, t)] = ll[o];
                if ((t = uu[o]) != -1) dd[pii(t, y)] = dd[o];
                if ((t = dd[o]) != -1) uu[pii(t, y)] = uu[o];
                if (g[x][y] == 'U') x = uu[o];
                else if (g[x][y] == 'D') x = dd[o];
                else if (g[x][y] == 'L') y = ll[o];
                else if (g[x][y] == 'R') y = rr[o];
                else exit(0);
            }

            if (cur > mx) {
                mx = cur;
                cnt = 1;
            } else if (cur == mx) {
                cnt += 1;
            }

            memcpy(dd, d, sizeof d);
            memcpy(uu, u, sizeof u);
            memcpy(ll, l, sizeof l);
            memcpy(rr, r, sizeof r);
        }
    }
    cout << mx << ' ' << cnt;
}

int main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
#else
    freopen("1.txt", "r", stdin);
#endif
    york();
    return 0;
}
