#include <bits/stdc++.h>
using namespace std;
long long n, m, p, astf, astg;
long long f[1000006], g[1000006];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> p;
  for (int i = 0; i < n; ++i) {
    cin >> f[i];
    if (f[i] % p != 0) astf = i;
  }
  for (int i = 0; i < m; ++i) {
    cin >> g[i];
    if (g[i] % p != 0) astg = i;
  }
  cout << astf + astg << endl;
  return 0;
}
