#include <bits/stdc++.h>
using namespace std;
struct fenwick_tree {
  int n;
  vector<int> f;
  fenwick_tree(int n = 0) : n(n), f(n + 1) {}
  fenwick_tree(vector<int> &a) : fenwick_tree(a.size()) {
    for (int i = 0; i < n; i++) changeValue(i, a[i]);
  }
  void changeValue(int i, int d) {
    for (i++; i <= n; i += i & -i) f[i] += d;
  }
  int getSum(int i) {
    int s = 0;
    for (i++; i; i -= i & -i) s += f[i];
    return s;
  }
  int getSum(int l, int r) { return getSum(r - 1) - getSum(l - 1); }
};
struct sparse_table {
  int n;
  vector<int> a;
  vector<vector<int>> st;
  int combine(int dl, int dr) {
    return a[dl] < a[dr] || a[dl] == a[dr] && dl < dr ? dl : dr;
  }
  sparse_table() {}
  sparse_table(vector<int> &a)
      : n(a.size()), a(a), st((31 - __builtin_clz(n)) + 1, vector<int>(n)) {
    for (int i = 0; i < n; i++) st[0][i] = i;
    for (int j = 1; 1 << j <= n; j++)
      for (int i = 0; i + (1 << j) <= n; i++)
        st[j][i] = combine(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);
  }
  int query(int l, int r) {
    int s = (31 - __builtin_clz(r - l));
    return combine(st[s][l], st[s][r - (1 << s)]);
  }
};
int n, m, x, a[200100], ia[200100], b[200100], ib[200100];
bool ua[200100], ub[200100];
int ar[200100], ra[200100], ru[200100], rl[200100], bta[200100];
fenwick_tree ft(200100);
void merge(int i, int j) {
  ft.changeValue(max(ra[i], ra[j]), -1);
  ra[i] = min(ra[i], ra[j]);
  ar[ru[j]] = i;
  ar[rl[j]] = i;
  ru[i] = max(ru[i], ru[j]);
  rl[i] = min(rl[i], rl[j]);
}
void create(int i) {
  ft.changeValue(a[i], 1);
  ar[i] = i, ra[i] = a[i];
  ru[i] = rl[i] = i;
  ua[i] = true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) cin >> a[i], ia[i] = i;
  a[n] = x + 1;
  ia[n] = n;
  n++;
  sort(ia, ia + n, [&](int i, int j) { return a[i] < a[j]; });
  vector<int> bs;
  for (int i = 0; i < m; i++) cin >> b[i], ib[i] = i, bs.push_back(b[i]);
  sort(ib, ib + m, [&](int i, int j) { return b[i] > b[j]; });
  sparse_table st(bs);
  set<pair<int, int>> brs;
  brs.emplace(0, m);
  bta[st.query(0, m)] = a[ia[0]];
  for (int ca = 0, cb = 0; ca < n; ca++) {
    int i = ia[ca];
    while (cb < m && a[i] + b[ib[cb]] > x) {
      int j = ib[cb];
      auto it = --brs.lower_bound({j + 1, j + 1});
      int l = it->first, r = it->second;
      brs.erase(it);
      int cbi = st.query(l, r);
      if (l < j) {
        int obi = st.query(l, j);
        brs.emplace(l, j);
        if (obi != cbi) bta[obi] = a[i];
      }
      if (j + 1 < r) {
        int obi = st.query(j + 1, r);
        brs.emplace(j + 1, r);
        if (obi != cbi) bta[obi] = a[i];
      }
      cb++;
    }
  }
  long long res = 0;
  for (int ca = 0, cb = 0; ca < n; ca++) {
    int i = ia[ca];
    while (cb < m && a[i] + b[ib[cb]] > x) {
      int j = ib[cb];
      if (bta[j]) res += ft.getSum(bta[j], x + 1);
      cb++;
    }
    create(i);
    if (i > 0 && ua[i - 1]) merge(ar[i - 1], ar[i]);
    if (i < n - 1 && ua[i + 1]) merge(ar[i], ar[i + 1]);
  }
  cout << res << "\n";
}
