#include using namespace std; int main() { int64_t n, m, k; cin >> n >> m >> k; char op; cin >> op; vector a(n), b(m); for (int i = 0; i < m; i++) { cin >> b.at(i); b.at(i) %= k; } for (int i = 0; i < n; i++) { cin >> a.at(i); a.at(i) %= k; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); if (op == '+') { int64_t ans = (upper_bound(a.begin(), a.end(), 0) - lower_bound(a.begin(), a.end(), 0)) * (upper_bound(b.begin(), b.end(), 0) - lower_bound(b.begin(), b.end(), 0)); for (int i = 0; i < n; i++) { ans += upper_bound(b.begin(), b.end(), k - a.at(i)) - lower_bound(b.begin(), b.end(), k - a.at(i)); } cout << ans << endl; } else { return 1; } }