#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653;
const long long infi = 1000000001;
const string no = "NO\n", yes = "YES\n", nl = "\n";
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  long long n, m, i, length, bank, p, k, j, x, y, ans, q;
  string s;
  while (t--) {
    ans = 0;
    cin >> n >> m >> p;
    long long in1, in2;
    for (i = 0; i < n; i++) {
      cin >> x;
      if (x % p) in1 = i;
    }
    for (i = 0; i < m; i++) {
      cin >> x;
      if (x % p) in2 = i;
    }
    cout << in1 + in2 << nl;
  }
  return 0;
}
