#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, p;
  int ans1 = -1, ans2 = -1;
  scanf("%d %d %d", &n, &m, &p);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (ans1 == -1 && a % p != 0) ans1 = i;
  }
  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    if (ans2 == -1 && a % p != 0) ans2 = i;
  }
  printf("%d\n", ans1 + ans2);
}
