#include <bits/stdc++.h>
using namespace std;
void resolve() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  int i1 = 0, i2 = 0;
  int ans = 0;
  while (1) {
    if (a[i1] % p == 0)
      i1++;
    else if (b[i2] % p == 0)
      i2++;
    else {
      cout << ans;
      break;
    }
    ans++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  resolve();
}
