#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, p;
  cin >> n >> m >> p;
  int x = -1, y = -1;
  for (int i = 0; i < n; i++) {
    int elm;
    cin >> elm;
    if (x > -1) continue;
    if (elm % p != 0) x = i;
  }
  for (int i = 0; i < m; i++) {
    int elm;
    cin >> elm;
    if (y > -1) continue;
    if (elm % p != 0) y = i;
  }
  cout << x + y << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
