#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int u;
  long long int v;
};
bool compare(string p, string q) { return (p + q > q + p); };
void dfs(vector<long long int> adj[], vector<char>& ans, long long int vis[],
         long long int x) {
  ans.push_back(x);
  vis[x] = 1;
  for (auto p : adj[x]) {
    if (!vis[p]) {
      dfs(adj, ans, vis, p);
    }
  }
}
void set_bit(vector<long long int>& n_bit, long long int n) {
  long long int i = 0;
  while (n) {
    if (n & 1)
      n_bit.push_back(1);
    else
      n_bit.push_back(0);
    n /= 2;
    i++;
  }
}
long long int recur(vector<vector<long long int> >& dp, long long int i,
                    long long int j, long long int prev, long long int h,
                    vector<long long int>& v, long long int n, long long int l,
                    long long int r) {
  if (i >= n) return 0;
  if (dp[prev][i] != -1) return dp[prev][i];
  long long int a = 0, b = 0;
  if (((v[i] - 1 + prev) % h) >= l && ((v[i] - 1 + prev) % h) <= r) a = 1;
  if (((v[i] + prev) % h) >= l && ((v[i] + prev) % h) <= r) b = 1;
  dp[prev][i] =
      max(recur(dp, i + 1, 1, (v[i] + prev) % h, h, v, n, l, r) + b,
          recur(dp, i + 1, 0, (v[i] + prev - 1) % h, h, v, n, l, r) + a);
  return dp[prev][i];
}
int main() {
  long long int t = 1;
  while (t--) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n, m, p;
    cin >> n >> m >> p;
    vector<long long int> ar, br;
    for (long long int i = 0; i < n; i++) {
      long long int a;
      cin >> a;
      ar.push_back(a);
    };
    for (long long int i = 0; i < m; i++) {
      long long int a;
      cin >> a;
      br.push_back(a);
    };
    long long int count = 0;
    for (long long int i = 0; i < n; i++) {
      if (ar[i] % p != 0) {
        count += i;
        break;
      }
    }
    for (long long int i = 0; i < m; i++) {
      if (br[i] % p != 0) {
        count += i;
        break;
      }
    }
    cout << count << "\n";
  }
  return 0;
}
