#include <bits/stdc++.h>
int read() {
  int r = 0, t = 1, c = getchar();
  while (c < '0' || c > '9') {
    t = c == '-' ? -1 : 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = (r << 3) + (r << 1) + (c ^ 48);
    c = getchar();
  }
  return r * t;
}
const int N = 400010, M = 200000;
int n, m, t;
int a[N], b[N];
int A[N], B[N];
std::vector<int> q[N], Q[N];
void solve(int *a, int n, int *A, int d) {
  static int s[N], m[N], t;
  t = 0;
  for (int i = (1), end_i = (n); i <= end_i; i++) {
    int M = a[i];
    while (t && a[i] > a[s[t]]) {
      M = std::min(M, m[t]);
      t--;
    }
    if (t && d == 0) A[i] = std::min(A[i], ::t - M);
    while (t && a[i] == a[s[t]]) {
      M = std::min(M, m[t]);
      t--;
    }
    if (t && d == 1) A[i] = std::min(A[i], ::t - M);
    t++;
    s[t] = i;
    m[t] = M;
  }
}
int s[N];
void Modify(int p, int v) {
  for (; p <= M; p += p & (-p)) s[p] += v;
}
int query(int p) {
  int ans = 0;
  p++;
  for (; p; p &= p - 1) ans += s[p];
  return ans;
}
void modify(int l, int r) {
  l++;
  r++;
  Modify(l, 1);
  Modify(r, -1);
}
int main() {
  n = read();
  m = read();
  t = M + M - read();
  for (int i = (1), end_i = (n); i <= end_i; i++) {
    a[i] = M - read();
    A[i] = M + 1;
  }
  for (int i = (1), end_i = (m); i <= end_i; i++) {
    b[i] = M - read();
    B[i] = M + 1;
  }
  solve(a, n, A, 1);
  std::reverse(a + 1, a + n + 1);
  std::reverse(A + 1, A + n + 1);
  solve(a, n, A, 0);
  std::reverse(a + 1, a + n + 1);
  std::reverse(A + 1, A + n + 1);
  solve(b, m, B, 1);
  std::reverse(b + 1, b + m + 1);
  std::reverse(B + 1, B + m + 1);
  solve(b, m, B, 0);
  std::reverse(b + 1, b + m + 1);
  std::reverse(B + 1, B + m + 1);
  for (int i = (1), end_i = (n); i <= end_i; i++) {
    int l = std::max(t - a[i], 0), r = A[i];
    if (l < r) {
      q[l].push_back(a[i]);
      q[r].push_back(-a[i]);
    }
  }
  for (int i = (1), end_i = (m); i <= end_i; i++) Q[b[i]].push_back(i);
  long long ans = 0;
  for (int i = (M + M), end_i = (0); i >= end_i; i--) {
    for (auto j : Q[i]) {
      int l = std::max(t - b[j], 0), r = B[j];
      if (l < r) {
        modify(l, r);
      }
    }
    for (auto j : q[i]) {
      int x, y;
      if (j > 0) {
        x = 1;
        y = j;
      } else {
        x = -1;
        y = -j;
      }
      ans += x * query(y);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
