This is an easier version of the problem H without modification queries.

Lester and Delbert work at an electronics company. They are currently working on a microchip component serving to connect two independent parts of a large supercomputer.

The component is built on top of a breadboard — a grid-like base for a microchip. The breadboard has n rows and m columns, and each row-column intersection contains a node. Also, on each side of the breadboard there are ports that can be attached to adjacent nodes. Left and right side have n ports each, and top and bottom side have m ports each. Each of the ports is connected on the outside to one of the parts bridged by the breadboard, and is colored red or blue respectively.

<image>

Ports can be connected by wires going inside the breadboard. However, there are a few rules to follow:

  * Each wire should connect a red port with a blue port, and each port should be connected to at most one wire.
  * Each part of the wire should be horizontal or vertical, and turns are only possible at one of the nodes.
  * To avoid interference, wires can not have common parts of non-zero length (but may have common nodes). Also, a wire can not cover the same segment of non-zero length twice.



The capacity of the breadboard is the largest number of red-blue wire connections that can be made subject to the rules above. For example, the breadboard above has capacity 7, and one way to make seven connections is pictured below.

<image>

Up to this point statements of both versions are identical. Differences follow below.

Given the current breadboard configuration, help Lester and Delbert find its capacity efficiently.

Input

The first line contains three integers n, m, q (1 ≤ n, m ≤ 10^5, \pmb{q = 0}). n and m are the number of rows and columns of the breadboard respectively. In this version q is always zero, and is only present for consistency with the harder version.

The next four lines describe initial coloring of the ports. Each character in these lines is either R or B, depending on the coloring of the respective port. The first two of these lines contain n characters each, and describe ports on the left and right sides respectively from top to bottom. The last two lines contain m characters each, and describe ports on the top and bottom sides respectively from left to right.

Output

Print a single integer — the given breadboard capacity.

Example

Input


4 5 0
BBRR
RBBR
BBBBB
RRRRR


Output


7
#include <bits/stdc++.h>
using namespace std;
int n, m, f[100510][2];
char ch[4][100510];
int main() {
  scanf("%d%d%*d", &n, &m);
  scanf("%s%s%s%s", ch[0] + 1, ch[1] + 1, ch[2] + 1, ch[3] + 1);
  for (int i = 1; i <= m; i++) {
    if (ch[2][i] == 'R')
      f[1][1]++;
    else
      f[1][0]++;
  }
  if (ch[0][1] == 'R')
    f[1][1]++;
  else
    f[1][0]++;
  if (ch[1][1] == 'R')
    f[1][1]++;
  else
    f[1][0]++;
  for (int i = 2; i <= n; i++) {
    int c0 = 0, c1 = 0;
    if (ch[0][i] == 'R')
      c1++;
    else
      c0++;
    if (ch[1][i] == 'R')
      c1++;
    else
      c0++;
    f[i][1] = min(f[i - 1][0] + m, f[i - 1][1]) + c1;
    f[i][0] = min(f[i - 1][1] + m, f[i - 1][0]) + c0;
  }
  for (int i = 1; i <= m; i++) {
    if (ch[3][i] == 'R')
      f[n][1]++;
    else
      f[n][0]++;
  }
  int ans = min(f[n][0], f[n][1]);
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    if (ch[0][i] == 'R')
      f[1][1]++;
    else
      f[1][0]++;
  }
  if (ch[2][1] == 'R')
    f[1][1]++;
  else
    f[1][0]++;
  if (ch[3][1] == 'R')
    f[1][1]++;
  else
    f[1][0]++;
  for (int i = 2; i <= m; i++) {
    int c0 = 0, c1 = 0;
    if (ch[2][i] == 'R')
      c1++;
    else
      c0++;
    if (ch[3][i] == 'R')
      c1++;
    else
      c0++;
    f[i][0] = min(f[i - 1][0], f[i - 1][1] + n) + c0;
    f[i][1] = min(f[i - 1][1], f[i - 1][0] + n) + c1;
  }
  for (int i = 1; i <= n; i++) {
    if (ch[1][i] == 'R')
      f[m][1]++;
    else
      f[m][0]++;
  }
  ans = min(ans, min(f[m][0], f[m][1]));
  printf("%d\n", ans);
}
