#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
int main() {
  int n, m, p, a = -1, b = -1, x;
  scanf("%d %d %d", &n, &m, &p);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (a == -1 && x % p != 0) a = i;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &x);
    if (b == -1 && x % p != 0) b = i;
  }
  printf("%d\n", a + b);
  return 0;
}
