#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, p;
  cin >> n >> m >> p;
  long long int a[n], b[m];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ind1 = -1, ind2 = -1;
  for (long long int i = 0; i < n; i++) {
    if (a[i] % p != 0) {
      ind1 = i;
      break;
    }
  }
  for (long long int i = 0; i < m; i++) {
    if (b[i] % p != 0) {
      ind2 = i;
      break;
    }
  }
  cout << ind1 + ind2 << endl;
}
