#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, p, j = -1, k = -1, temp;
  cin >> n >> m >> p;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp % p && j == -1) j = i;
  }
  for (int i = 0; i < m; i++) {
    cin >> temp;
    if (temp % p && k == -1) k = i;
  }
  cout << j + k << endl;
  return 0;
}
