#include <bits/stdc++.h>
using namespace std;
int n, m, p, a[1000001], b[1000001], sum;
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] %= p;
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]), b[i] %= p;
  for (int i = 1; i <= n; i++)
    if (a[i] % p) {
      sum = i;
      break;
    }
  for (int i = 1; i <= m; i++)
    if (b[i] % p) {
      printf("%d", sum + i - 2);
      break;
    }
  return 0;
}
