#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long int n, m, p;
  unsigned long long int temp, x = 0, y = 0;
  cin >> n >> m >> p;
  vector<int> A, B;
  for (unsigned long long int i = 0; i < n; i++) {
    cin >> temp;
    A.push_back(temp % p);
  }
  for (unsigned long long int i = 0; i < m; i++) {
    cin >> temp;
    B.push_back(temp % p);
  }
  for (unsigned long long int i = 0; i < n; i++) {
    if (A[i] != 0) {
      x = i;
      break;
    }
  }
  for (unsigned long long int i = 0; i < m; i++) {
    if (B[i] != 0) {
      y = i;
      break;
    }
  }
  cout << x + y;
  return 0;
}
