#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, p;
  cin >> n >> m >> p;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  vector<long long> b(m);
  for (long long i = 0; i < m; ++i) cin >> b[i];
  for (long long i = 0; i < n; ++i) {
    bool flag = false;
    if (a[i] % p != 0) {
      for (long long j = 0; j < m; ++j) {
        if (b[j] % p != 0) {
          flag = true;
          cout << i + j;
          break;
        }
      }
      if (flag) {
        break;
      }
    }
  }
  return 0;
}
