#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int N = 1e5 + 5;
const int M = 105;
const int INF = 0x3f3f3f3f;
const long long LINF = 1e17;
const unsigned long long sed = 31;
const long long mod = (1ll << 32);
const double eps = 1e-8;
const double PI = 3.14159265358979;
long long n, m, p;
int x1, x2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> p;
  for (int i = 0; i < n; i++) {
    long long t;
    cin >> t;
    if (t % p) x1 = i;
  }
  for (int i = 0; i < m; i++) {
    long long t;
    cin >> t;
    if (t % p) x2 = i;
  }
  cout << x1 + x2 << endl;
  return 0;
}
