#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const double PI = acos(-1);
long long powmod(long long a, long long b, long long p) {
  long long res = 1;
  while (b)
    if (b & 1)
      res = (long long)(res * 1ll * a % p), --b;
    else
      a = (long long)(a * 1ll * a % p), b >>= 1;
  return res;
}
long long generator(long long p) {
  vector<long long> fact;
  long long phi = p - 1, n = phi;
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) {
      fact.push_back(i);
      while (n % i == 0) n /= i;
    }
  if (n > 1) fact.push_back(n);
  for (long long res = 2; res <= p; ++res) {
    bool ok = true;
    for (size_t i = 0; i < fact.size() && ok; ++i)
      ok &= powmod(res, phi / fact[i], p) != 1;
    if (ok) return res;
  }
  return -1;
}
long long mod, root, root_1, root_pw;
void fft(vector<long long>& a, bool invert) {
  long long n = a.size();
  for (long long i = 1, j = 0; i < n; i++) {
    long long bit = n >> 1;
    for (; j & bit; bit >>= 1) j ^= bit;
    j ^= bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (long long len = 2; len <= n; len <<= 1) {
    long long wlen = invert ? root_1 : root;
    for (long long i = len; i < root_pw; i <<= 1)
      wlen = (long long)(1LL * wlen * wlen % mod);
    for (long long i = 0; i < n; i += len) {
      long long w = 1;
      for (long long j = 0; j < len / 2; j++) {
        long long u = a[i + j],
                  v = (long long)(1LL * a[i + j + len / 2] * w % mod);
        a[i + j] = u + v < mod ? u + v : u + v - mod;
        a[i + j + len / 2] = u - v >= 0 ? u - v : u - v + mod;
        w = (long long)(1LL * w * wlen % mod);
      }
    }
  }
  if (invert) {
    long long n_1 = powmod(n, mod - 2, mod);
    for (long long& x : a) x = (long long)(1LL * x * n_1 % mod);
  }
}
vector<long long> multiply(vector<long long> const& a,
                           vector<long long> const& b) {
  vector<long long> fa(a.begin(), a.end()), fb(b.begin(), b.end());
  long long n = 1;
  while (n < a.size() + b.size()) n <<= 1;
  fa.resize(n);
  fb.resize(n);
  fft(fa, false);
  fft(fb, false);
  for (long long i = 0; i < n; i++) fa[i] *= fb[i];
  fft(fa, true);
  vector<long long> result(n);
  for (long long i = 0; i < n; i++) result[i] = fa[i];
  return result;
}
long long m, n, p;
int main() {
  scanf("%lld", &n);
  scanf("%lld", &m);
  scanf("%lld", &p);
  long long x;
  long long a = -1, b = -1;
  std::vector<long long> A, B;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    if (a == -1 and x % p) a = i;
    A.push_back(x);
  }
  for (int i = 0; i < m; i++) {
    scanf("%lld", &x);
    if (b == -1 and x % p) b = i;
    B.push_back(x);
  }
  cout << a + b << endl;
}
