#include <bits/stdc++.h>
using namespace std;
template <typename T>
void setmax(T& x, T y) {
  x = max(x, y);
}
template <typename T>
void setmin(T& x, T y) {
  x = min(x, y);
}
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const long long LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string arr[2][2];
int sz[2], q;
struct node {
  int t;
  int dp[2][2][2][2];
  node(int T = 0) : t(T) {
    for (int i = (0); i < (2); ++i) {
      for (int j = (0); j < (2); ++j) {
        for (int col = (0); col < (2); ++col) {
          dp[col][1 - col][i][j] = INF;
          dp[col][col][i][j] = 0;
        }
      }
    }
  }
  void print() {
    for (int i = (0); i < (2); ++i)
      for (int j = (0); j < (2); ++j) cout << dp[i][j][0][0] << " ";
    cout << endl;
  }
  node operator+(node x) {
    node res;
    res.t = t;
    assert(t == x.t);
    for (int i = (0); i < (2); ++i)
      for (int j = (0); j < (2); ++j)
        for (int colL1 = (0); colL1 < (2); ++colL1) {
          for (int colR2 = (0); colR2 < (2); ++colR2) {
            res.dp[colL1][colR2][i][j] = INF;
            for (int colR1 = (0); colR1 < (2); ++colR1) {
              for (int colL2 = (0); colL2 < (2); ++colL2) {
                int tmp = dp[colL1][colR1][i][j] + x.dp[colL2][colR2][i][j] +
                          sz[1 - t] * (colR1 ^ colL2);
                setmin(res.dp[colL1][colR2][i][j], tmp);
              }
            }
          }
        }
    return res;
  }
  void sw(int x) {
    for (int i = (0); i < (2); ++i)
      for (int j = (0); j < (2); ++j)
        for (int k = (0); k < (2); ++k) {
          if (x)
            swap(dp[i][j][k][0], dp[i][j][k][1]);
          else
            swap(dp[i][j][0][k], dp[i][j][1][k]);
        }
  }
};
struct Tree1 {
  int T;
  node t[1 << 19];
  int in[1 << 19][2];
  void push(int v, int tl, int tr, int tm) {
    if (in[v][tm] == 0) return;
    in[v][tm] = 0;
    if (tl == tr) return;
    t[2 * v].sw(tm);
    in[2 * v][tm] ^= 1;
    t[2 * v + 1].sw(tm);
    in[2 * v + 1][tm] ^= 1;
  }
  void push(int v, int tl, int tr) {
    for (int i = (0); i < (2); ++i) push(v, tl, tr, i);
  }
  node get(int v, int tl, int tr, int l, int r) {
    if (l > r) return node(T);
    push(v, tl, tr);
    if (tl == l && tr == r) return t[v];
    int tm = (tl + tr) / 2;
    node res1 = get(2 * v, tl, tm, l, min(r, tm));
    node res2 = get(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
    res1 = res1 + res2;
    return res1;
  }
  void upd(int v, int tl, int tr, int l, int r, int which) {
    if (l > r) return;
    push(v, tl, tr);
    if (tl == l && tr == r) {
      in[v][which] = 1;
      t[v].sw(which);
      return;
    }
    int tm = (tl + tr) / 2;
    upd(2 * v, tl, tm, l, min(r, tm), which);
    upd(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, which);
    t[v] = t[2 * v] + t[2 * v + 1];
  }
  void build(int v, int l, int r) {
    t[v].t = T;
    if (l == r) {
      for (int i = (0); i < (2); ++i) {
        for (int j = (0); j < (2); ++j) {
          int colu = (arr[T][0][r] == 'R') ^ i;
          int cold = (arr[T][1][l] == 'R') ^ j;
          for (int col = (0); col < (2); ++col) {
            t[v].dp[col][col][i][j] = (colu != col) + (cold != col);
            t[v].dp[col][1 - col][i][j] = INF;
          }
        }
      }
      return;
    }
    int m = (l + r) / 2;
    build(2 * v, l, m);
    build(2 * v + 1, m + 1, r);
    t[v] = t[2 * v] + t[2 * v + 1];
  }
} T1[2];
struct Tree2 {
  int t[1 << 19];
  int in[1 << 19];
  void build(int v, int l, int r, int i, int j) {
    if (l == r) {
      t[v] = (arr[i][j][l] == 'R');
      return;
    }
    int m = (l + r) / 2;
    build(2 * v, l, m, i, j);
    build(2 * v + 1, m + 1, r, i, j);
    t[v] = t[2 * v] + t[2 * v + 1];
  }
  void push(int v, int tl, int tr) {
    if (in[v] == 0) return;
    in[v] = 0;
    if (tl == tr) return;
    int tm = (tl + tr) / 2;
    in[2 * v] ^= 1;
    t[2 * v] = tm - tl + 1 - t[2 * v];
    in[2 * v + 1] ^= 1;
    t[2 * v + 1] = tr - (tm + 1) + 1 - t[2 * v + 1];
  }
  void upd(int v, int tl, int tr, int l, int r) {
    if (l > r) return;
    push(v, tl, tr);
    if (tl == l && tr == r) {
      in[v] ^= 1;
      t[v] = tr - tl + 1 - t[v];
      return;
    }
    int tm = (tl + tr) / 2;
    upd(2 * v, tl, tm, l, min(tm, r));
    upd(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
    t[v] = t[2 * v] + t[2 * v + 1];
  }
  int get(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    push(v, tl, tr);
    if (tl == l && tr == r) return t[v];
    int tm = (tl + tr) / 2;
    return get(2 * v, tl, tm, l, min(tm, r)) +
           get(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
  }
} T2[2][2];
int solve() {
  int ans = INF;
  for (int i = (0); i < (2); ++i) {
    node res = T1[i].get(1, 0, sz[i] - 1, 0, sz[i] - 1);
    for (int colL = (0); colL < (2); ++colL) {
      for (int colR = (0); colR < (2); ++colR) {
        int tmp = res.dp[colL][colR][0][0];
        if (colL)
          tmp += sz[1 - i] -
                 T2[1 - i][0].get(1, 0, sz[1 - i] - 1, 0, sz[1 - i] - 1);
        else
          tmp += T2[1 - i][0].get(1, 0, sz[1 - i] - 1, 0, sz[1 - i] - 1);
        if (colR)
          tmp += sz[1 - i] -
                 T2[1 - i][1].get(1, 0, sz[1 - i] - 1, 0, sz[1 - i] - 1);
        else
          tmp += T2[1 - i][1].get(1, 0, sz[1 - i] - 1, 0, sz[1 - i] - 1);
        setmin(ans, tmp);
      }
    }
  }
  return ans;
}
void upd(char x, int l, int r) {
  int t1, t2;
  if (x == 'U') t1 = 1, t2 = 0;
  if (x == 'D') t1 = 1, t2 = 1;
  if (x == 'L') t1 = 0, t2 = 0;
  if (x == 'R') t1 = 0, t2 = 1;
  T1[t1].upd(1, 0, sz[t1] - 1, l, r, t2);
  T2[t1][t2].upd(1, 0, sz[t1] - 1, l, r);
}
void prec() {
  for (int i = (0); i < (2); ++i) {
    for (int j = (0); j < (2); ++j) {
      T2[i][j].build(1, 0, sz[i] - 1, i, j);
    }
    T1[i].T = i;
    T1[i].build(1, 0, sz[i] - 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> sz[0] >> sz[1] >> q;
  for (int i = (0); i < (2); ++i)
    for (int j = (0); j < (2); ++j) cin >> arr[i][j];
  prec();
  cout << solve() << endl;
  while (q--) {
    char x;
    int l, r;
    cin >> x >> l >> r;
    l--;
    r--;
    upd(x, l, r);
    cout << solve() << endl;
  }
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}
