#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m, x, wa, wb, mxa[maxn], mxb[maxn], a[maxn], b[maxn], tr[maxn];
stack<int> st;
int mx[maxn];
inline void add(int x, int y) {
  for (int i = x; i <= N; i += i & (-i)) tr[i] += y;
}
inline int query(int x) {
  int res = 0;
  for (int i = x; i >= 1; i -= i & (-i)) res += tr[i];
  return res;
}
inline void work(int *A, int *MXA, int len, int tag) {
  memset(mx, 0, sizeof(mx));
  while (!st.empty()) st.pop();
  for (int i = 1; i <= len; i++) {
    while (!st.empty() && A[st.top()] >= A[i] + 1 - tag)
      mx[i] = max(mx[i], mx[st.top()]), st.pop();
    st.push(i);
    mx[i] = max(mx[i], A[i]);
    if (tag)
      MXA[i] = (st.size() > 1 ? mx[i] : x);
    else if (st.size() > 1)
      MXA[len - i + 1] = min(MXA[len - i + 1], mx[i]);
  }
}
vector<int> I[maxn], D[maxn];
vector<pair<int, int> > p[maxn];
int main() {
  n = read(), m = read(), x = read();
  for (int i = 1; i <= n; i++) a[i] = read(), wa = max(wa, a[i]);
  for (int i = 1; i <= m; i++) b[i] = read(), wb = max(wb, b[i]);
  work(a, mxa, n, 1);
  reverse(a + 1, a + 1 + n);
  work(a, mxa, n, 0);
  reverse(a + 1, a + 1 + n);
  work(b, mxb, m, 1);
  reverse(b + 1, b + 1 + m);
  work(b, mxb, m, 0);
  reverse(b + 1, b + 1 + m);
  for (int i = 1; i <= m; i++) {
    if (b[i] >= x) continue;
    p[b[i]].push_back(make_pair(x - mxb[i], x - b[i]));
  }
  for (int i = 1; i <= n; i++) {
    int u = max(x - mxa[i] + 1, 1), v = x - a[i];
    if (a[i] >= x || u > v) continue;
    I[u].push_back(a[i]), D[v].push_back(a[i]);
  }
  long long res = 0;
  for (int i = 1; i <= wb; i++) {
    for (int j = 0; j < I[i].size(); j++) add(I[i][j], 1);
    for (int j = 0; j < p[i].size(); j++)
      res += query(p[i][j].second) - query(p[i][j].first);
    for (int j = 0; j < D[i].size(); j++) add(D[i][j], -1);
  }
  printf("%lld\n", res);
  return 0;
}
