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>
using namespace std;
int **mas, **test, **error;
int n, m;
int Max = 0, Max_count = 0;
void clear_test(int ***test) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      (*test)[i][j] = 0;
    }
  }
  return;
};
int answer(int I, int J) {
  if (!error[I][J] && mas[I][J] == -1) return 0;
  int t;
  if (error[I][J]) switch (error[I][J] / 6000) {
      case 0:
        t = 3;
        break;
      case 1:
        t = 2;
        break;
      case 2:
        t = 0;
        break;
      case 3:
        t = 1;
        break;
      default:
        t = mas[I][J];
        break;
    }
  else
    t = mas[I][J];
  bool fl = true;
  int temp = 0;
  switch (t) {
    case 0:
      temp = 0;
      for (int i = I + 1; i < n; i++) {
        if (!test[i][J] && mas[i][J] != -1) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 2)) {
            return (error[I][J] % 12000 - temp) + answer(i, J);
          } else
            return 1 + answer(i, J);
        } else if (!test[i][J] && mas[i][J] == -1 && (error[i][J]) &&
                   (error[i][J] / 6000 != 2)) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 2)) {
            return (error[I][J] % 12000 - temp) + answer(i, J);
          } else
            return 1 + answer(i, J);
        } else {
          if (test[i][J] && mas[i][J] == -1 && fl && (error[i][J]) &&
              (error[i][J] / 6000 == 2))
            temp++;
          else {
            fl = false;
            if (!test[i][J] && mas[i][J] == -1 && (error[i][J]) &&
                (error[i][J] / 6000 == 2))
              test[i][J] = 1;
          }
        }
      };
      break;
    case 1:
      temp = 0;
      for (int i = I - 1; i >= 0; i--) {
        if (!test[i][J] && mas[i][J] != -1) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 3)) {
            return (error[I][J] % 18000 - temp) + answer(i, J);
          } else
            return 1 + answer(i, J);
        } else if (!test[i][J] && mas[i][J] == -1 && (error[i][J]) &&
                   (error[i][J] / 6000 != 3)) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 3)) {
            return (error[I][J] % 18000 - temp) + answer(i, J);
          } else
            return 1 + answer(i, J);
        } else {
          if (test[i][J] && mas[i][J] == -1 && fl && (error[i][J]) &&
              (error[i][J] / 6000 == 3))
            temp++;
          else {
            fl = false;
            if (!test[i][J] && mas[i][J] == -1 && (error[i][J]) &&
                (error[i][J] / 6000 == 3))
              test[i][J] = 1;
          }
        }
      }
      break;
    case 2:
      for (int j = J - 1; j >= 0; j--) {
        if (!test[I][j] && mas[I][j] != -1) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 1)) {
            return (error[I][J] % 6000 - temp) + answer(I, j);
          } else
            return 1 + answer(I, j);
        } else if (!test[I][j] && mas[I][j] == -1 && (error[I][j]) &&
                   (error[I][j] / 6000 != 1)) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 1)) {
            return (error[I][J] % 6000 - temp) + answer(I, j);
          } else
            return 1 + answer(I, j);
        } else {
          if (test[I][j] && mas[I][j] == -1 && fl && (error[I][j]) &&
              (error[I][j] / 6000 == 1))
            temp++;
          else {
            fl = false;
            if (!test[I][j] && mas[I][j] == -1 && (error[I][j]) &&
                (error[I][j] / 6000 == 1))
              test[I][j] = 1;
          }
        }
      }
      break;
    case 3:
      for (int j = J + 1; j < m; j++) {
        if (!test[I][j] && mas[I][j] != -1) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 0)) {
            return (error[I][J] - temp) + answer(I, j);
          } else
            return 1 + answer(I, j);
        } else if (!test[I][j] && mas[I][j] == -1 && (error[I][j]) &&
                   (error[I][j] / 6000 != 0)) {
          test[I][J] = 1;
          if (error[I][J] && (error[I][J] / 6000 == 0)) {
            return (error[I][J] - temp) + answer(I, j);
          } else
            return 1 + answer(I, j);
        } else {
          if (test[I][j] && mas[I][j] == -1 && fl && (error[I][j]) &&
              (error[I][j] / 6000 == 0))
            temp++;
          else {
            fl = false;
            if (!test[I][j] && mas[I][j] == -1 && (error[I][j]) &&
                (error[I][j] / 6000 == 0))
              test[I][j] = 1;
          };
        }
      }
      break;
    default:;
  }
  if (error[I][J]) return error[I][J] % 6000 - temp;
  return 1;
};
void set_error_right(int row, int beg, int end) {
  for (int i = beg; i <= end; i++) error[row][i] = end - i + 1;
  for (int i = beg + 1; i <= end; i++) mas[row][i] = -1;
};
void set_error_left(int row, int beg, int end) {
  for (int i = end; i <= beg; i++) error[row][i] = i - end + 1 + 6000;
  for (int i = end; i < beg; i++) mas[row][i] = -1;
}
void set_error_down(int column, int beg, int end) {
  for (int i = beg; i <= end; i++) {
    error[i][column] = end - i + 1 + 12000;
  }
  for (int i = beg + 1; i <= end; i++) mas[i][column] = -1;
}
void set_error_up(int column, int beg, int end) {
  for (int i = beg; i <= end; i++) error[i][column] = i - end + 1 + 18000;
  error[beg][column] = beg - end + 1 + 18000;
  for (int i = end; i < beg; i++) mas[i][column] = -1;
}
int main() {
  scanf("%d %d", &n, &m);
  mas = (int **)calloc(n, sizeof(int *));
  test = (int **)calloc(n, sizeof(int *));
  error = (int **)calloc(n, sizeof(int *));
  for (int i = 0; i < n; i++) {
    mas[i] = (int *)calloc(m, sizeof(int));
    test[i] = (int *)calloc(m, sizeof(int));
    error[i] = (int *)calloc(m, sizeof(int));
  }
  clear_test(&test);
  clear_test(&error);
  for (int i = 0; i < n; i++) {
    char *str = new char[m + 5];
    scanf("%s", str);
    int len = strlen(str);
    for (int j = 0; j < len; j++) {
      switch (str[j]) {
        case 'D':
          mas[i][j] = 0;
          break;
        case 'U':
          mas[i][j] = 1;
          break;
        case 'L':
          mas[i][j] = 2;
          break;
        case 'R':
          mas[i][j] = 3;
          break;
        case '.':
          mas[i][j] = -1;
          break;
        default:;
      }
    }
    delete[] str;
  }
  for (int i = 0; i < n; i++) {
    int j = 0;
    int beg = -1, end;
    while (j < m) {
      if (mas[i][j] == 3) {
        beg = j;
        while (j < m && mas[i][j] == 3) {
          j++;
        }
        if (j - beg > 1) {
          end = j - 1;
          set_error_right(i, beg, end);
        }
      } else
        j++;
    }
    beg = -1;
    j = m - 1;
    while (j >= 0) {
      if (mas[i][j] == 2) {
        beg = j;
        while (j >= 0 && mas[i][j] == 2) {
          j--;
        }
        if (beg - j > 1) {
          end = j + 1;
          set_error_left(i, beg, end);
        }
      } else
        j--;
    }
  }
  for (int j = 0; j < m; j++) {
    int i = 0;
    int beg = -1, end;
    while (i < n) {
      if (mas[i][j] == 0) {
        beg = i;
        while (i < n && mas[i][j] == 0) {
          i++;
        }
        if (i - beg > 1) {
          end = i - 1;
          set_error_down(j, beg, end);
        }
      } else
        i++;
    }
    i = n - 1;
    beg = -1;
    while (i >= 0) {
      if (mas[i][j] == 1) {
        beg = i;
        while (i >= 0 && mas[i][j] == 1) {
          i--;
        }
        if (beg - i > 1) {
          end = i + 1;
          set_error_up(j, beg, end);
        }
      } else
        i--;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      clear_test(&test);
      int temp = answer(i, j);
      if (temp > Max) {
        Max = temp;
        Max_count = 1;
      } else {
        if (Max == temp) {
          Max_count++;
        }
      }
    }
  }
  printf("%d %d\n", Max, Max_count);
  return 0;
}
