#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void get_it_done() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  if (a < b) return gcd(b, a);
  return gcd(b, a % b);
}
const long long N = 1e6 + 5;
long long a[N], b[N];
long long n, m, p;
int32_t main() {
  get_it_done();
  long long q = 1;
  while (q--) {
    cin >> n >> m >> p;
    for (long long i = 0; i < n; ++i) cin >> a[i];
    for (long long i = 0; i < m; ++i) cin >> b[i];
    long long ans = -1;
    for (long long i = 0; i < n; ++i) {
      if (a[i] % p) {
        ans = i;
        break;
      }
    }
    for (long long i = 0; i < m; ++i) {
      if (b[i] % p) {
        ans += i;
        break;
      }
    }
    cout << ans << "\n";
  }
}
