#include <bits/stdc++.h>
using namespace std;
void PUNKS_NOT_DEAD() {
  int n, m, p;
  cin >> n >> m >> p;
  int ax;
  vector<int> posi, posj;
  vector<bool> goodi(n), goodj(m);
  for (int i = 0; i < n; i++) {
    cin >> ax;
    if (ax % p != 0) {
      posi.push_back(i);
      goodi[i] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> ax;
    if (ax % p != 0) {
      posj.push_back(i);
      goodj[i] = 1;
    }
  }
  for (int mod1 = 0; mod1 < 2; mod1++) {
    for (int mod2 = 0; mod2 < 2; mod2++) {
      int i = (mod1 == 0 ? posi[0] : posi.back());
      int j = (mod2 == 0 ? posj[0] : posj.back());
      bool good = true;
      for (int ii = i - 1, jj = j + 1; ii >= 0 && jj < m; ii--, jj++) {
        if (goodi[ii] and goodj[jj]) {
          good = false;
          break;
        }
      }
      for (int ii = i + 1, jj = j - 1; ii < n && jj >= 0; ii++, jj--) {
        if (goodi[ii] and goodj[jj]) {
          good = false;
          break;
        }
      }
      if (good) {
        cout << i + j;
        exit(0);
      }
    }
  }
  assert(false);
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  PUNKS_NOT_DEAD();
}
