#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int maxx = 1e6 + 10;
const long long mod = 1e9 + 7;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
long long a[maxx], b[maxx];
int main() {
  int n, m, p;
  cin >> n >> m >> p;
  for (int i = 0; i < n; i++) a[i] = read();
  for (int i = 0; i < m; i++) b[i] = read();
  int x, y;
  for (int i = 0; i < n; i++) {
    if (a[i] % p) {
      x = i;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    if (b[i] % p) {
      y = i;
      break;
    }
  }
  cout << x + y << endl;
}
