#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int INF = 0x3F3F3F3F;
const int64_t LINF = 4611686018427387903;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 9;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> arr(n), arrr(m);
  for (int i = 0; i < n; i++) cin >> arr[i], arr[i] %= p;
  for (int i = 0; i < m; i++) cin >> arrr[i], arrr[i] %= p;
  int l, r;
  for (int i = 0; i < n; i++) {
    if (arr[i]) {
      l = i;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    if (arrr[i]) {
      r = i;
      break;
    }
  }
  cout << l + r << '\n';
  return 0;
}
