#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
const ll mod = 1000000007;
void testCase() {
  int n, m, p;
  cin >> n >> m >> p;
  int ans = 0;
  int flg = 1;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    if (flg && v % p != 0) {
      ans += i;
      flg = 0;
    }
  }
  flg = 1;
  for (int i = 0; i < m; i++) {
    int v;
    cin >> v;
    if (flg && v % p != 0) {
      ans += i;
      flg = 0;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  testCase();
  return 0;
}
