#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000000 + 10;
int a[maxn], b[maxn], c[maxn];
int ok_a[maxn], ok_b[maxn];
int main() {
  int n, m, p;
  scanf("%d %d %d", &n, &m, &p);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    if (a[i] % p == 0) {
      ok_a[i] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", b + i);
    if (b[i] % p == 0) {
      ok_b[i] = 1;
    }
  }
  int pos1 = 0, pos2 = 0;
  for (int i = 0; i < n; i++) {
    if (!ok_a[i]) {
      pos1 = i;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    if (!ok_b[i]) {
      pos2 = i;
      break;
    }
  }
  int ans = pos1 + pos2;
  printf("%d\n", ans);
  getchar();
  getchar();
  return 0;
}
