#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, p, i = -1, j = -1;
  ios::sync_with_stdio(false);
  cin >> n >> m >> p;
  for (register int k = 0, x; k < n; k++) {
    cin >> x;
    if (i == -1 && x % p) i = k;
  }
  for (register int k = 0, x; k < m; k++) {
    cin >> x;
    if (j == -1 && x % p) j = k;
  }
  cout << i + j;
  return 0;
}
