#include <bits/stdc++.h>
using namespace std;
long long arr[2000001];
long long brr[2000001];
int n, m, ns, ms;
long long p;
int main(void) {
  scanf("%d %d %lld", &n, &m, &p);
  int chk = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    if (!chk && arr[i] % p) {
      chk = 1;
      ns = i;
    }
  }
  chk = 0;
  for (int i = 0; i < m; i++) {
    scanf("%lld", &brr[i]);
    if (!chk && brr[i] % p) {
      chk = 1;
      ms = i;
    }
  }
  printf("%d", ms + ns);
  return 0;
}
