#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, p;
  cin >> n >> m >> p;
  long long a[n], b[m];
  long long c1, c2;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < m; i++) cin >> b[i];
  for (long long i = 0; i < n; i++) {
    if (a[i] % p) {
      c1 = i;
      break;
    }
  }
  for (long long i = 0; i < m; i++) {
    if (b[i] % p) {
      c2 = i;
      break;
    }
  }
  cout << c1 + c2;
}
