#include <bits/stdc++.h>
int max2(int len, int *nums) {
  int i, _max = nums[0];
  for (i = 1; i < len; i++) {
    if (nums[i] > _max) _max = nums[i];
  }
  return _max;
}
void inp_str(int instr[]) {
  char *ptr;
  int z, i, count;
  char str[100] = {'\0'};
  char *ln;
  fgets(str, 100, stdin);
  ln = strchr(str, '\n');
  if (ln != NULL) {
    *ln = '\0';
  } else {
    while (1) {
      z = getchar();
      if (z == '\n' || z == EOF) break;
    }
  }
  count = 0;
  ptr = strtok(str, " ");
  i = atoi(ptr);
  instr[count] = i;
  count = count + 1;
  while (ptr != NULL) {
    ptr = strtok(NULL, " ");
    if (ptr != NULL) {
      i = atoi(ptr);
      instr[count] = i;
      count = count + 1;
    }
  }
}
int main(void) {
  int input1[120];
  inp_str(input1);
  int input2[120];
  inp_str(input2);
  int N, M;
  N = input1[0];
  M = N;
  int A;
  A = max2(N, input2);
  int i;
  for (i = 0; i < N; i = i + 1) {
    if (input2[N - i - 1] == A) break;
    if (input2[N - i - 1] < A) M = M - 1;
  }
  int count = 0;
  for (i = 0; i < M - 1; i = i + 1) {
    if (input2[0] <= input2[i + 1]) count = count + 1;
  }
  count = count + 1;
  printf("%d\n", count);
  return 0;
}
