#include <bits/stdc++.h>
using namespace std;
long long int a[200009];
long long int fun(long long int x, long long int z) {
  if (x > z) {
    return 1;
  }
  return -1;
}
int main() {
  map<long long int, long long int> m;
  long long int i, n, index = 0, m1;
  cin >> n >> m1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == m1) index = i;
  }
  long long int cnt = 1, z = 0, sum = 0;
  m[z]++;
  for (int i = index - 1; i >= 1; i--) {
    sum = sum + fun(a[i], m1);
    m[sum]++;
    if (sum == 0) cnt++;
  }
  sum = 0;
  for (int i = index + 1; i <= n; i++) {
    sum = sum + fun(a[i], m1);
    if (m[-sum]) {
      cnt = cnt + m[-sum];
    }
  }
  m.clear();
  sum = 0;
  for (int i = index; i >= 1; i--) {
    sum = sum + fun(a[i], m1);
    m[sum]++;
    if (sum == 0) cnt++;
  }
  sum = 0;
  for (int i = index + 1; i <= n; i++) {
    sum = sum + fun(a[i], m1);
    if (m[-sum]) {
      cnt = cnt + m[-sum];
    }
  }
  cout << cnt;
}
