#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> 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 r;
  if (a[0] % p == 0) {
    if (b[0] % p != 0) {
      for (int i = 1; i < n; ++i) {
        if (a[i] % p != 0) {
          r = i;
          break;
        }
      }
    } else {
      int i = 1;
      while (1) {
        if (a[i] % p == 0 && b[i] % p == 0) {
          ++i;
        } else {
          break;
        }
      }
      if (a[i] % p != 0) {
        if (b[i] % p == 0) {
          for (int j = i + 1; j < m; ++j) {
            if (b[j] % p != 0) {
              r = j + i;
              break;
            }
          }
        } else {
          r = i * 2;
        }
      } else {
        if (b[i] % p != 0) {
          for (int j = i + 1; j < n; ++j) {
            if (a[j] % p != 0) {
              r = j + i;
              break;
            }
          }
        }
      }
    }
  } else {
    if (b[0] % p == 0) {
      for (int i = 1; i < m; ++i) {
        if (b[i] % p != 0) {
          r = i;
          break;
        }
      }
    } else {
      r = 0;
    }
  }
  cout << r << endl;
}
