#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  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;
  return 0;
}
