#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll maxn = 2e6 + 5;
ll A[maxn], B[maxn];
inline int Read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int main() {
  ll m, n, p;
  cin >> m >> n >> p;
  for (int i = 0; i < m; i++) A[i] = Read();
  for (int i = 0; i < n; i++) B[i] = Read();
  ll res;
  for (int i = 0; i < m; i++) {
    if (A[i] % p) {
      res += i;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (B[i] % p) {
      res += i;
      break;
    }
  }
  cout << res << endl;
  return 0;
}
