The Little Elephant has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.

The Little Elephant wants to count, how many pairs of integers l and r are there, such that 1 ≤ l < r ≤ n and sequence b = a1a2... alarar + 1... an has no more than k inversions. 

An inversion in sequence b is a pair of elements of the sequence b, that change their relative order after a stable sorting of the sequence. In other words, an inversion is a pair of integers i and j, such that 1 ≤ i < j ≤ |b| and bi > bj, where |b| is the length of sequence b, and bj is its j-th element.

Help the Little Elephant and count the number of the described pairs.

Input

The first line contains two integers n and k (2 ≤ n ≤ 105, 0 ≤ k ≤ 1018) — the size of array a and the maximum allowed number of inversions respectively. The next line contains n positive integers, separated by single spaces, a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of array a.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Output

In a single line print a single number — the answer to the problem.

Examples

Input

3 1
1 3 2


Output

3


Input

5 2
1 3 2 1 7


Output

6
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 10;
struct Node {
  Node *lch, *rch;
  int seg;
  Node() {
    seg = 0;
    lch = rch = nullptr;
  }
} * root[MAX_N];
void build(int l, int r, Node*& node) {
  node = new Node();
  if (l != r) {
    int mid = (l + r) >> 1;
    build(l, mid, node->lch);
    build(mid + 1, r, node->rch);
  }
}
Node* modify(int l, int r, int pos, Node* pre) {
  Node* now = new Node();
  *now = *pre;
  now->seg++;
  if (l != r) {
    int mid = (l + r) >> 1;
    if (pos <= mid)
      now->lch = modify(l, mid, pos, pre->lch);
    else
      now->rch = modify(mid + 1, r, pos, pre->rch);
  }
  return now;
}
int query(int l, int r, int x, Node* node) {
  if (l == r) {
    return l > x ? node->seg : 0;
  } else {
    int mid = (l + r) >> 1;
    if (x <= mid)
      return query(l, mid, x, node->lch) + node->rch->seg;
    else
      return query(mid + 1, r, x, node->rch);
  }
}
int a[MAX_N], bit[MAX_N];
vector<int> tmp;
inline int lowbit(int _x) { return _x & -_x; }
void bitUpdate(int pos) {
  for (int i = pos; i <= (int)tmp.size(); i += lowbit(i)) bit[i]++;
}
int bitQuery(int pos) {
  int res = 0;
  for (int i = pos; i > 0; i -= lowbit(i)) res += bit[i];
  return res;
}
long long Lnum[MAX_N];
int main() {
  int N;
  long long K;
  scanf("%d%lld", &N, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%d", a + i);
    tmp.push_back(a[i]);
  }
  sort(tmp.begin(), tmp.end());
  tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
  build(1, tmp.size(), root[0]);
  for (int i = 1; i <= N; i++) {
    a[i] = lower_bound(tmp.begin(), tmp.end(), a[i]) - tmp.begin() + 1;
    Lnum[i] = query(1, tmp.size(), a[i], root[i - 1]) + Lnum[i - 1];
    root[i] = modify(1, tmp.size(), a[i], root[i - 1]);
  }
  int l = N - 1;
  long long ans = N - 1, num = 0;
  bitUpdate(a[N]);
  for (int i = 1; i < N; i++) {
    if (Lnum[i] + num + (a[i] > a[N] ? 1 : 0) > K) {
      l = i - 1;
      ans = l;
      break;
    }
    if (a[i] > a[N]) num++;
  }
  if (l > 0) {
    for (int r = N - 1; r > 1; r--) {
      if (l > r - 1) {
        num -= bitQuery(a[l] - 1);
        l--;
      }
      num += bitQuery(a[r] - 1) + query(1, tmp.size(), a[r], root[l]);
      bitUpdate(a[r]);
      while (l > 0 && num + Lnum[l] > K) {
        num -= bitQuery(a[l] - 1);
        l--;
      }
      if (l == 0) break;
      ans += l;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
