#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6) {
    if (n % i == 0 || n % (i + 2) == 0) return false;
  }
  return true;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (a < b) swap(a, b);
  return gcd(a % b, b);
}
long long gcdextended(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1, gcd = gcdextended(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long modinverse(long long a, long long m) {
  long long x, y;
  long long g = gcdextended(a, m, x, y);
  if (g != 1) {
    cout << "NOT POSSIBLE";
    return -1;
  } else
    return (x % m + m) % m;
}
long long po(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long pom(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long root(long long x, vector<long long> &id) {
  while (id[x] != x) {
    id[x] = id[id[x]];
    x = id[x];
  }
  return x;
}
void uni(long long x, long long y, vector<long long> &id) {
  long long a = root(x, id);
  long long b = root(y, id);
  id[a] = id[b];
}
bool sec(const pair<pair<long long, long long>, long long> &a,
         const pair<pair<long long, long long>, long long> &b) {
  return (a.first.first - a.first.second) < (b.first.first - b.first.second);
}
void bfs(long long second, vector<vector<long long> > &v,
         vector<long long> &vis, vector<pair<long long, long long> > &dis) {
  vis[second] = 1;
  queue<long long> q;
  long long p, i, st = second;
  if (st == 1)
    dis[second].first = 0;
  else
    dis[second].second = 0;
  q.push(second);
  while (!q.empty()) {
    p = q.front();
    q.pop();
    for (i = 0; i < v[p].size(); i++) {
      if (!vis[v[p][i]]) {
        if (st == 1)
          dis[v[p][i]].first = dis[p].first + 1;
        else
          dis[v[p][i]].second = dis[p].second + 1;
        vis[v[p][i]] = 1;
        q.push(v[p][i]);
      }
    }
  }
}
void solve() {
  long long n, m, i, p, x, in, inn;
  cin >> n >> m >> p;
  for (i = 0; i < n; i++) {
    scanf("%lld", &x);
    if ((x % p) != 0) in = i;
  }
  for (i = 0; i < m; i++) {
    scanf("%lld", &x);
    if ((x % p) != 0) inn = i;
  }
  printf("%lld", in + inn);
}
int main() {
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
