#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1000000 + 5;
int a[N], b[N], n, m, p;
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  int i = 0, j = 0;
  while (a[i] % p == 0) i++;
  while (b[j] % p == 0) j++;
  cout << i + j << endl;
  return 0;
}
