#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N], b[N], na[N], nb[N], t1[N], t2[N], c[N], tp, q[N], mx[N], x, n, m, i,
    j;
long long ans;
void init(int* a, int* ans, int n) {
  for (memset(ans, 0x3f, (n + 3) << 2), tp = 0, i = 1; i <= n; ++i) {
    j = a[i];
    while (tp && a[i] < a[q[tp]]) j = max(j, mx[tp--]);
    if (tp) ans[i] = min(ans[i], j);
    q[++tp] = i;
    mx[tp] = j;
  }
  for (tp = 0, i = n; i; --i) {
    j = a[i];
    while (tp && a[i] <= a[q[tp]]) j = max(j, mx[tp--]);
    if (tp) ans[i] = min(ans[i], j);
    q[++tp] = i;
    mx[tp] = j;
  }
}
void A(int x, int C) {
  while (x < N) c[x] += C, x += x & -x;
}
int Q(int x, int C = 0) {
  while (x > 0) C += c[x], x -= x & -x;
  return C;
}
int main() {
  for (scanf("%d%d%d", &n, &m, &x), i = 1; i <= n; ++i)
    scanf("%d", a + i), t1[i] = i;
  for (i = 1; i <= m; ++i) scanf("%d", b + i), t2[i] = i;
  init(a, na, n);
  init(b, nb, m);
  sort(t1 + 1, t1 + n + 1, [&](int x, int y) { return a[x] < a[y]; });
  sort(t2 + 1, t2 + m + 1, [&](int x, int y) { return nb[x] < nb[y]; });
  for (i = 1, j = m; i <= n; ++i) {
    while (j && a[t1[i]] + nb[t2[j]] > x) A(b[t2[j--]], 1);
    ans += Q(x - a[t1[i]]) - Q(x - na[t1[i]]);
  }
  printf("%lld\n", ans);
}
