#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mai;
int main() {
  long long i, j, k = 0, l, a, c, b = 0, ans = 0, right_one = 0, right_zero = 0,
                  right_minus = 0, left_one = 0, left_zero = 0, left_minus = 0;
  long n;
  cin >> n >> c;
  long vec[200100];
  for (i = 0; i < n; i++) {
    cin >> vec[i];
    if (vec[i] == c) l = i;
  }
  for (i = l - 1; i >= 0; i--) {
    if (vec[i] < c) b--;
    if (vec[i] > c) b++;
    if (b == 0 || b == 1) {
      ans++;
    }
    mai[b]++;
  }
  b = 0;
  for (i = l + 1; i < n; i++) {
    if (vec[i] < c) b--;
    if (vec[i] > c) b++;
    if (b == 0 || b == 1) {
      ans++;
    }
    ans = ans + mai[-b];
    ans = ans + mai[1 - b];
  }
  cout << ans + 1;
  return 0;
}
