#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  long long p;
  cin >> n >> m >> p;
  long long ar1[n], ar2[m];
  for (int i = 0; i < n; i++) {
    cin >> ar1[i];
    ar1[i] %= p;
  }
  for (int i = 0; i < m; i++) {
    cin >> ar2[i];
    ar2[i] %= p;
  }
  int p1 = 0, p2 = 0;
  for (int i = 0; i < n; i++) {
    if (ar1[i] != 0) {
      p1 = i;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    if (ar2[i] != 0) {
      p2 = i;
      break;
    }
  }
  cout << p1 + p2 << endl;
  ;
}
