#pragma region #include "bits/stdc++.h" #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++) #define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--) #define _rep2(i, n) _rep3(i, 0, n) #define _irep2(i, n) _irep3(i, 0, n) #define _overload3(_1, _2, _3, name, ...) name #define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__) #define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__) #define out(x) cout << (x) << '\n'; #define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl; using namespace std; using ll = long long; using vi = vector; using vl = vector; using vvi = vector>; using vvl = vector>; template istream &operator>>(istream &is, vector &vec) { for (auto &v : vec) is >> v; return is; } template istream &operator>>(istream &is, pair &pair) { cin >> pair.first >> pair.second; return is; } template ostream &operator<<(ostream &os, const vector &vec) { os << "[ "; rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i]; os << " ]"; return os; } template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } void init() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(16) << boolalpha; } #pragma endregion #define MOD 1000000007 #define INF 2147483647 int main() { init(); int N, M; ll K; cin >> N >> M >> K; char op; vl A(N), B(M); cin >> op >> B >> A; ll ans = 0; if (op == '+') { rep(i, M) B[i] = K - B[i]; sort(all(B)); rep(i, N) ans += upper_bound(all(B), A[i]) - B.begin(); } else { rep(i, M) B[i] = (K + B[i] - 1) / B[i]; sort(all(B)); rep(i, N) ans += upper_bound(all(B), A[i]) - B.begin(); } out(ans); }