1548_E. Gregor and the Two Painters_7
Two painters, Amin and Benj, are repainting Gregor's living room ceiling! The ceiling can be modeled as an n × m grid.

For each i between 1 and n, inclusive, painter Amin applies a_i layers of paint to the entire i-th row. For each j between 1 and m, inclusive, painter Benj applies b_j layers of paint to the entire j-th column. Therefore, the cell (i,j) ends up with a_i+b_j layers of paint.

Gregor considers the cell (i,j) to be badly painted if a_i+b_j ≤ x. Define a badly painted region to be a maximal connected component of badly painted cells, i. e. a connected component of badly painted cells such that all adjacent to the component cells are not badly painted. Two cells are considered adjacent if they share a side.

Gregor is appalled by the state of the finished ceiling, and wants to know the number of badly painted regions.

Input

The first line contains three integers n, m and x (1 ≤ n,m ≤ 2⋅ 10^5, 1 ≤ x ≤ 2⋅ 10^5) — the dimensions of Gregor's ceiling, and the maximum number of paint layers in a badly painted cell.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2⋅ 10^5), the number of paint layers Amin applies to each row.

The third line contains m integers b_1, b_2, …, b_m (1 ≤ b_j ≤ 2⋅ 10^5), the number of paint layers Benj applies to each column.

Output

Print a single integer, the number of badly painted regions.

Examples

Input


3 4 11
9 8 5
10 6 7 2


Output


2


Input


3 4 12
9 8 5
10 6 7 2


Output


1


Input


3 3 2
1 2 1
1 2 1


Output


4


Input


5 23 6
1 4 3 5 2
2 3 1 6 1 5 5 6 1 3 2 6 2 3 1 6 1 4 1 6 1 5 5


Output


6

Note

The diagram below represents the first example. The numbers to the left of each row represent the list a, and the numbers above each column represent the list b. The numbers inside each cell represent the number of paint layers in that cell.

The colored cells correspond to badly painted cells. The red and blue cells respectively form 2 badly painted regions.

<image>
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable {
 public:
  int n;
  vector<vector<T>> mat;
  F func;
  SparseTable(const vector<T>& a, const F& f) : func(f) {
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    mat.resize(max_log);
    mat[0] = a;
    for (int j = 1; j < max_log; j++) {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++) {
        mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
      }
    }
  }
  T get(int from, int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 32 - __builtin_clz(to - from + 1) - 1;
    return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};
template <typename T>
class fenwick {
 public:
  vector<T> fenw;
  int n;
  fenwick(int _n) : n(_n) { fenw.resize(n); }
  void modify(int x, T v) {
    while (x < n) {
      fenw[x] += v;
      x |= (x + 1);
    }
  }
  T get(int x) {
    T v{};
    while (x >= 0) {
      v += fenw[x];
      x = (x & (x + 1)) - 1;
    }
    return v;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = min(a[i], x);
  }
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    b[i] = min(b[i], x);
  }
  long long V = 0;
  long long E = 0;
  long long F = 0;
  {
    auto sa = a;
    sort(sa.begin(), sa.end());
    auto sb = b;
    sort(sb.begin(), sb.end());
    int j = m;
    for (int i = 0; i < n; i++) {
      while (j > 0 && sb[j - 1] + sa[i] > x) {
        --j;
      }
      V += j;
    }
  }
  {{vector<int> sa(n - 1);
  for (int i = 0; i < n - 1; i++) {
    sa[i] = max(a[i], a[i + 1]);
  }
  sort(sa.begin(), sa.end());
  auto sb = b;
  sort(sb.begin(), sb.end());
  int j = m;
  for (int i = 0; i < n - 1; i++) {
    while (j > 0 && sb[j - 1] + sa[i] > x) {
      --j;
    }
    E += j;
  }
}
{
  auto sa = a;
  sort(sa.begin(), sa.end());
  vector<int> sb(m - 1);
  for (int i = 0; i < m - 1; i++) {
    sb[i] = max(b[i], b[i + 1]);
  }
  sort(sb.begin(), sb.end());
  int j = m - 1;
  for (int i = 0; i < n; i++) {
    while (j > 0 && sb[j - 1] + sa[i] > x) {
      --j;
    }
    E += j;
  }
}
}
{
  auto Make = [&](const vector<int>& v) {
    int sz = (int)v.size();
    vector<int> pr(sz), ne(sz);
    for (int i = 0; i < sz; i++) {
      pr[i] = i - 1;
      ne[i] = i + 1;
    }
    vector<int> order(sz);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](int i, int j) { return v[i] > v[j]; });
    SparseTable<int> st(v, [&](int i, int j) { return max(i, j); });
    vector<tuple<int, int, int>> ret;
    for (int i = 0; i < sz - 1; i++) {
      ret.emplace_back(max(v[i], v[i + 1]), x, max(v[i], v[i + 1]));
    }
    for (int i : order) {
      if (pr[i] >= 0 && ne[i] < sz) {
        int v0 = max(v[pr[i]], v[ne[i]]);
        int v1 = v[i];
        int v2 = st.get(pr[i], ne[i]);
        if (v0 < v1) {
          ret.emplace_back(v0, v1, v2);
        }
      }
      if (pr[i] != -1) {
        ne[pr[i]] = ne[i];
      }
      if (ne[i] != sz) {
        pr[ne[i]] = pr[i];
      }
    }
    return ret;
  };
  vector<tuple<int, int, int>> r = Make(a);
  vector<tuple<int, int, int>> c = Make(b);
  42;
  42;
  vector<vector<pair<int, int>>> qs(x + 1);
  for (auto& q : c) {
    qs[x - get<2>(q)].emplace_back(x - get<1>(q) + 1, x - get<0>(q));
  }
  vector<vector<int>> ev(x + 1);
  for (auto& p : r) {
    ev[get<0>(p)].push_back(get<2>(p));
    ev[get<1>(p)].push_back(~get<2>(p));
  }
  fenwick<int> fenw(x + 1);
  for (int i = 1; i <= x; i++) {
    for (int e : ev[i]) {
      if (e >= 1) {
        fenw.modify(e, +1);
      } else {
        fenw.modify(~e, -1);
      }
    }
    for (auto& q : qs[i]) {
      F += fenw.get(q.second) - fenw.get(q.first - 1);
    }
  }
}
cout << V - E + F << '\n';
return 0;
}
