#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  const int num = (int(1e6));
  int n, m, p, i, f = -1, g = -1, t;
  cin >> n >> m >> p;
  for (i = 0; i < n; ++i) {
    cin >> t;
    if (t % p != 0) {
      f = i;
      break;
    }
  }
  for (++i; i < n; ++i) cin >> t;
  for (i = 0; i < m; ++i) {
    cin >> t;
    if (t % p != 0) {
      g = i;
      break;
    }
  }
  for (++i; i < m; ++i) cin >> t;
  cout << f + g << endl;
  return 0;
}
