#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, m, p;
const double PI = acos(-1);
vector<int> a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> m >> p;
  for (int i = (int)1; i <= (int)n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  for (int i = (int)1; i <= (int)m; i++) {
    int x;
    cin >> x;
    b.push_back(x);
  }
  int i = 0, j = 0;
  while (i < n) {
    if (a[i] % p != 0) break;
    i++;
  }
  while (j < m) {
    if (b[j] % p != 0) break;
    j++;
  }
  cout << i + j << endl;
}
