#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    long long n, m, p;
    cin >> n >> m >> p;
    long long 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 << endl;
  }
}
