#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
const long long inf = 1e15;
const int INF = (0x3f3f3f3f);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, p;
  int t1 = 0, t2 = 0;
  cin >> n >> m >> p;
  int a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % p != 0) t1 = i;
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    if (b[i] % p != 0) t2 = i;
  }
  cout << t2 + t1 << '\n';
}
