#include <bits/stdc++.h>
using namespace std;
long long int a[2000000];
long long int b[2000000];
pair<long long int, long long int> coeff[7];
long long int power(long long int N, long long int R) {
  if (N < R) return 0;
  if (R == 0)
    return 1;
  else
    return N * power(N - 1, R - 1) / R;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, p;
  cin >> n >> m >> p;
  memset(coeff, 0, 5);
  long long int ind1, ind2;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= p;
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] != 0) {
      ind1 = i;
      break;
    }
  }
  for (long long int j = 0; j < m; j++) {
    cin >> b[j];
    b[j] %= p;
  }
  for (long long int j = 0; j < m; j++) {
    if (b[j] != 0) {
      ind2 = j;
      break;
    }
  }
  cout << ind1 + ind2;
}
