#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  int n, m, p;
  cin >> n >> m >> p;
  int a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % p != 0) {
      x = i;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    if (b[i] % p != 0) {
      y = i;
      break;
    }
  }
  cout << x + y;
}
