#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long n, m, p;
    cin >> n >> m >> p;
    long long 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];
    long long x = 0, y = 0;
    for (int i = 0; i < n; i++) {
      if ((a[i] == 1) || ((a[i] % p != 0) && (p % a[i] != 0))) {
        x = i;
        break;
      }
    }
    for (int i = 0; i < m; i++) {
      if ((b[i] == 1) || ((b[i] % p != 0) && (p % b[i] != 0))) {
        y = i;
        break;
      }
    }
    cout << x + y << '\n';
  }
  return 0;
}
