#include <bits/stdc++.h>
int main() {
  int N, A, B, C;
  int MP = 0;
  scanf("%d %d %d %d", &N, &A, &B, &C);
  int l[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &l[i]);
  }
  for (int i = 0; i < N; i++) {
    if (l[i] == A) {
      A = 0;
    } else if (l[i] == B) {
      B = 0;
    } else if (l[i] == C) {
      C = 0;
    }
  }
  if (A == 0 && B == 0; C == 0) {
    printf("%d", 0);
  }
}
