#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void solve() {
  long long n, m, p;
  cin >> n >> m >> p;
  vector<int> A(n);
  vector<int> B(m);
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int j = 0; j < m; j++) cin >> B[j];
  int c1 = 0, c2 = 0;
  int cnt = 0;
  while (true) {
    if (A[c1] % p == 0)
      c1++;
    else if (B[c2] % p == 0)
      c2++;
    else {
      cout << cnt << endl;
      return;
    }
    cnt++;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  solve();
  return 0;
}
