#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
long long a[maxn], b[maxn];
int main() {
  int n, m, p;
  scanf("%d%d%d", &n, &m, &p);
  long long ans = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (ans == -1 && a[i] % p) ans = i - 1;
  }
  long long res = -1;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    if (res == -1 && b[i] % p) res = i - 1;
  }
  long long cnm = ans + res;
  cout << cnm;
  return 0;
}
