#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, m, p;
  cin >> n >> m >> p;
  vector<long long> a(n);
  for (long long k = 0; k < n; k++) {
    cin >> a[k];
  }
  vector<long long> b(m);
  for (long long k = 0; k < m; k++) {
    cin >> b[k];
  }
  long long i = 0;
  while (a[i] % p == 0) {
    i++;
  }
  long long j = 0;
  while (b[j] % p == 0) {
    j++;
  }
  cout << i + j << "\n";
  return 0;
}
