#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  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 res = 0;
  for (int i = 0; i < n; i++)
    if (a[i] % p != 0) {
      res += i;
      break;
    }
  for (int i = 0; i < m; i++)
    if (b[i] % p != 0) {
      res += i;
      break;
    }
  cout << res;
  return 0;
}
