#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, p;
  cin >> n >> m >> p;
  int a = -1;
  int b = -1;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp % p != 0 && a == -1) a = i;
  }
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    if (tmp % p != 0 && b == -1) b = i;
  }
  cout << a + b << endl;
}
