#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using pi = pair<int, int>;
const double PI = acos(-1.0);
const double eps = 1e-9;
const ll mod = 1e9 + 7;
const int inf = 1e7;
const int MAXN = 1e5 + 5;
void cp() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> A(n), B(m);
  for (int &x : A) cin >> x;
  for (int &x : B) cin >> x;
  int x = -1, y = -1;
  for (int i = 0; i < n && x == -1; i++)
    if (A[i] % p) x = i;
  for (int i = 0; i < m && y == -1; i++)
    if (B[i] % p) y = i;
  cout << x + y << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    cp();
  }
  return 0;
}
