#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 2;
int n, m, x;
int a[MAXN], b[MAXN];
int l[MAXN], r[MAXN];
int bit[MAXN];
int rnk[MAXN];
int ord[MAXN];
bool vis[MAXN];
void add(int pos, int val) {
  while (pos < MAXN) {
    bit[pos] += val;
    pos += pos & -pos;
  }
}
int query(int pos) {
  int s = 0;
  while (pos) {
    s += bit[pos];
    pos -= pos & -pos;
  }
  return s;
}
bool cmp(int A, int B) {
  if (a[A] == a[B]) return A > B;
  return a[A] > a[B];
}
int main() {
  scanf("%d%d%d", &n, &m, &x);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
  set<pair<int, int> > s;
  for (int i = 1; i <= n; ++i) ord[i] = i;
  sort(ord + 1, ord + 1 + n, cmp);
  for (int i = 1; i <= n; ++i) rnk[ord[i]] = i;
  vector<pair<int, int> > col;
  for (int i = 1; i <= m; ++i) col.push_back(make_pair(b[i], i));
  sort(col.begin(), col.end());
  int pt = 0;
  for (int i = 1; i <= m; ++i) l[i] = r[i] = n + 1;
  for (int i_ = 1; i_ <= n; ++i_) {
    int I = ord[i_];
    while (pt < col.size() && col[pt].first + a[I] <= x) {
      int i = col[pt++].second;
      if (!vis[i - 1] && !vis[i + 1]) {
        s.insert(make_pair(i, b[i]));
        l[i] = i_;
      } else if (vis[i - 1] && !vis[i + 1])
        ;
      else if (!vis[i - 1] && vis[i + 1])
        ;
      else if (vis[i - 1] && vis[i + 1]) {
        auto ite = s.upper_bound(make_pair(i, 0));
        auto pr = prev(ite);
        pair<int, int> nd;
        if (pr->second > ite->second)
          nd = *ite, r[pr->first] = i_;
        else
          nd = *pr, r[ite->first] = i_;
        s.erase(ite);
        s.erase(pr);
        s.insert(nd);
      }
      vis[i] = 1;
    }
  }
  long long ans = 0;
  reverse(col.begin(), col.end());
  reverse(ord + 1, ord + 1 + n);
  pt = 1;
  s.clear();
  memset(vis, 0, sizeof(vis));
  for (auto it : col) {
    int j = it.second;
    while (pt <= n && a[ord[pt]] + it.first <= x) {
      int i = ord[pt++];
      if (!vis[i - 1] && !vis[i + 1]) {
        s.insert(make_pair(i, a[i]));
        add(rnk[i], 1);
      }
      if (vis[i - 1] && vis[i + 1]) {
        auto ite = s.upper_bound(make_pair(i, 0));
        auto pr = prev(ite);
        if (pr->second > ite->second) {
          add(rnk[pr->first], -1);
          s.erase(pr);
        } else {
          add(rnk[ite->first], -1);
          s.erase(ite);
        }
      }
      vis[i] = 1;
    }
    if (r[j] > l[j]) {
      ans += query(r[j] - 1) - query(l[j] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
