#include <bits/stdc++.h>
#pragma target("avx")
using namespace std;
constexpr long long INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr long long LINF = 1e18;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
long long n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q,
    p;
int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> p;
  for (long long(i) = 0; (i) < (int)(n); (i)++) cin >> a[i];
  for (long long(i) = 0; (i) < (int)(m); (i)++) cin >> b[i];
  for (long long i = (0); i < (min(n, m)); i++) {
    if (a[i] % p == 0 && b[i] % p == 0) continue;
    if (a[i] % p != 0 && b[i] % p != 0) {
      cout << (i + i) << endl;
      return 0;
    } else {
      if (a[i] % p != 0) {
        ans = a[i] * b[i + 1];
      } else {
        ans = b[i] * a[i + 1];
      }
      if (ans % p != 0) {
        cout << (i + i + 1) << endl;
        return 0;
      }
    }
  }
  long long tmp1, tmp2;
  for (long long(i) = 0; (i) < (int)(n); (i)++) {
    if (a[i] % p != 0) tmp1 = i;
  }
  for (long long(i) = 0; (i) < (int)(m); (i)++) {
    if (b[i] % p != 0) tmp2 = i;
  }
  cout << (tmp1 + tmp2) << endl;
  return 0;
}
