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

import java.io.*;
import java.util.*;

public class C {
  static class Point {
    int x, y;
    Point(int _x, int _y) {
     x = _x; y = _y; 
    }
    public String toString() {
      return String.format("%d %d", x, y);
    }
  }
  static int n, m, vis[][], vid;
  static char a[][];
  static boolean valid(int x, int y) {
    return x >= 0 && y >= 0 && x < n && y < m;
  }
  static Point dp[][][];
  static String DIR = "DULR";
  static int dx[] = {1, -1, 0, 0};
  static int dy[] = {0,  0,-1, 1}; 
  static Point solve(int x, int y, int dir) {
    if (!valid(x, y)) {
      return null;
    }
    if (dp[x][y][dir] != null) {
      return dp[x][y][dir] = solve(dp[x][y][dir].x, dp[x][y][dir].y, dir);
    }
    if (vis[x][y] == vid || a[x][y] == '.') {
        return dp[x][y][dir] = solve(x + dx[dir], y + dy[dir], dir);
    }
    return dp[x][y][dir]=new Point(x, y);
  }
	public static void main (String args[]) throws Exception {		
		BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
    String tmp[] = in.readLine().split(" ");
    n = Integer.parseInt( tmp[0] ); m = Integer.parseInt( tmp[1] );
    a = new char[n][];
    for (int i=0; i < n; i++) {
      a[i] = in.readLine().toCharArray();
    }
    
    vis = new int[n][m];
    dp = new Point[n][m][4];
    vid = 0;
    int ans = 0, count = 0;
    for (int x=0; x < n; x++)
    for (int y=0; y < m; y++) 
    if (a[x][y] != '.') {
      ++vid;
      for (Point z[][] : dp)
      for (Point q[] : z)
        Arrays.fill(q, null);
      int len = 0;
      int cx = x, cy = y;
      while (valid(cx, cy)) {
        vis[cx][cy] = vid;
        Arrays.fill( dp[cx][cy], null );
        len++;
        Point z = solve(cx, cy, DIR.indexOf( a[cx][cy] ));
        if (z == null) break;
        cx = z.x;
        cy = z.y;
      }
      
      if (len > ans) {
        ans = len; count = 1; 
      } else if (len == ans) {
        count++;
      }
    }
    System.out.println( ans + " " + count );
	}
}
