#include <bits/stdc++.h>
using namespace std;
const long long M = 1e6 + 10;
long long n, m, a[M], b[M], p, Ai, Bi;
int32_t main() {
  cin >> n >> m >> p;
  for (long long i = 0; i < n; i++) scanf("%lld", a + i);
  for (long long i = 0; i < m; i++) scanf("%lld", b + i);
  for (long long i = 0; i < n; i++)
    if (a[i] % p != 0) {
      Ai = i;
      break;
    }
  for (long long i = 0; i < m; i++)
    if (b[i] % p != 0) {
      Bi = i;
      break;
    }
  cout << Ai + Bi << endl;
  return 0;
}
