#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, M = 2e6 + 7, INF = INT_MAX / 10;
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, p;
  cin >> n >> m >> p;
  int a1[n], a2[m];
  for (int i = 0; i < n; i++) cin >> a1[i];
  for (int i = 0; i < m; i++) cin >> a2[i];
  int p1, p2;
  for (p1 = 0; p1 < n; p1++) {
    if (a1[p1] % p) break;
  }
  for (p2 = 0; p2 < m; p2++) {
    if (a2[p2] % p) break;
  }
  int ans = p1 + p2;
  cout << ans;
  return 0;
}
