#include <bits/stdc++.h>
using namespace std;
const bool debug = false;
const int inf = 1000 * 1000 * 1000;
const int MAKSN = 1000 + 13;
const long long MOD = 123456789LL;
int n, m, k, l, x, y, a, b, p;
string s;
vector<int> v;
void readIn() {
  cin >> n >> m >> p;
  x = 0;
  for (int i = 0; i < (int)n; i++) {
    cin >> k;
    if (k % p != 0 && x == 0) {
      a = i;
      x = 1;
    }
  }
  for (int i = 0; i < (int)m; i++) {
    cin >> k;
    if (k % p != 0) {
      cout << a + i << "\n";
      return;
    }
  }
}
void solve() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  readIn();
  solve();
  return 0;
}
