/*
ID:
TASK:
LANG: C++14
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

/*** Typedef ***/
typedef long long ll;
//typedef long long int;
//typedef int ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef    long double   ld;

//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;

/*** Loops ***/
#define ffit(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
#define ff1(i,a,b) for(ll i = a; i < b; i++)
#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)
#define ff3(i,a,b,m) for(ll i = a; i <b; i+=m)
#define ipar(ar,n) ll ar[n]; ff1(i,0,n) cin>>ar[i];
#define opar(ar,n) ff1(i,0,n) cout<<ar[i]<<" ";
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/

#define PI acos(-1.0)
#define eps 1e-7
#define size1 15

/*** STLs ***/
#define cu continue
#define br break
#define rsz resize
#define ins insert
#define ft front
#define bk back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))
#define MN3(n1,n2,n3) min(n1,min(n2,n3))
#define MN4(n1,n2,n3,n4) min(n1,min(n2,min(n3,n4)))
#define MX3(n1,n2,n3) max(n1,max(n2,n3))
#define MX4(n1,n2,n3,n4) max(n1,max(n2,max(n3,n4)))
#define mxar(a,n) *max_element(a,a+n)
#define mnar(a,n) *min_element(a,a+n)
#define arr_sm(a,n) accumulate(a,a+n,0)
#define vc_sm(ve) accumulate(ve.begin(),ve.end(),0)
#define mx_vc(ve) *max_element(ve.begin(),ve.end())
#define mn_vc(ve) *min_element(ve.begin(),ve.end())
//#define endl " \n"

/*** STLs ***/
typedef vector <ll> vll;
#define vvll vector<vll>
typedef set <ll> sll;
typedef multiset <ll> msll;
//typedef multimap <ll> mpll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll, ll> > vpll;
typedef priority_queue <pair <ll, ll> > pqpll;
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ml unordered_map<ll,ll>
///typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<ll>   us;

///vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.

/*** Sorts ***/
#define czero(n)                    __builtin_popcountll(n) // count the number of 1's in the bit representation of a number
#define cenzero(n)                  __builtin_ctzll(n) // count the number of zereos from the end of the bit representation of a number until a 1
#define countbegzero(n)             __builtin_clzxll(n)
#define checkparity(n)              __builtin_parityll(n)// checks whether the number of bits are even or odd
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtgrt(v) sort(all(v), greater<ll>())
#define prsrt greater<pair<int,int>>()
/*** Some Prints ***/
#define ip(n) ll n; cin>>n;
#define ipp(n,k) ll n; cin>>n; ll k; cin>>k;
#define ip3(n,m,k) ll n; cin>>n;ll m;cin>>m; ll k; cin>>k;
#define kl    '\n'
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": ";
//#define ps(x,y)         fixed<<setprecision(y)<<x
#define inf             1e18
#define dbg(x) cout << '>' << #x << ':' << x << kl;
#define trc1(x)                   cerr<<#x<<": "<<x<<kl
#define trc2(x, y)                cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<kl
#define trc3(x, y, z)             cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<kl
#define trc4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<kl
#define trc5(a, b, c, d, e)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<kl
#define trc6(a, b, c, d, e, f)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<kl
#define w(x)             ll x; cin>>x; while(x--)
bool isPtSquare(long double x)
{
    long double sr = sqrt(x);
    return ((sr - floor(sr)) == 0);
}

ll facts(ll n,ll mod)
{
	ll prod=1;
	for(ll i=1;i<=n;i++)
	{
		prod=(prod*i)%mod;
	}
	return prod;
}

ll binpow(ll a, ll b, ll mod){
	ll ans = 1;
	while(b){
		if(b&1) ans*=a;
		a*=a;
		ans%=mod;
		a%=mod;
		b/=2;
	}
	return ans;
}
ll mod = 1e9+7;
vector<ll> factors(ll n){ // returns all factors of a given number
    ll lim = sqrt(n);
    vector<ll> f;
    for(int i = 1; i <= lim; i++){
        if(n % i == 0){
            f.push_back(i);
            f.push_back(n / i);
            if(i*i == n){
                f.pop_back();
            }
        }
    }
    return f;
}

ll ceilAB(ll a, ll b){
    return (a + b - 1) / b;
}
ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%mod;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%mod;

    if(pow%2==1)
    {
        ans=(ans*n)%mod;
    }
    return ans%mod;
}

const int mxn = 1e3;

ll fact[mxn + 1];
void calcfac(ll n, ll mod = 2e18){
	fact[0]  = 1;
	for(int i = 1; i<=n;++i){
		fact[i] = fact[i-1]*i;
		fact[i] %= mod;
	}
}

ll nCr(ll p, ll q, ll mod = 2e18){
	ll val = fact[p];
	ll invfact = fact[q]*fact[p-q];
	val%=mod;
	invfact%=mod;
	val*=binpow(invfact, mod - 2, mod);
	return val%mod;
}

ll nPr(ll p, ll q, ll mod = 2e18){
	ll val = nCr(p, q, mod);
	val*=fact[q];
	val%=mod;
	return val;
}

bool isprime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
ll power(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return (x * temp * temp);
        else
            return ((temp * temp) / x);
    }
}

//ll pmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
//void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
//ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
//{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

#define go(i, a) for (auto &i : a)
#define go1(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define mk(arr,n,type) type *arr=new type[n];
#define sz(obj) (int(obj.size()))
#define ipve(vc,n) vll vc(n); ff1(i,0,n){cin>>vc[i];}
#define ipvc(vc,n) vll vc; ff1(i,0,n){ip(x);vc.pb(x);}
#define depressed()                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//bool ans = all_of(arr, arr + 6, [](int x) {return x & 1; } );
const double pi = 3.141592653589793238460;
ll cbtr(ll n,ll m)
{
    ll sm = 1;
    ff1(i,1,m+1)
    {
        sm*=(n-i+1);
        sm/=i;
    }
    return sm;
}
//string a="cdefghijklmnopqrstuvwxyz";
ld f(ld n)
{
    ld sm = 1;
    ff1(i,1,n+1)
    {
        sm*=i;
    }
    return sm;
}
ld pc(ld n, ld k)
{
    ld sm = f(n)/f(n-k);
    return sm;
}
vll prime;
void seive(ll n)
{
    prime.resize(n+1,1);
    iota(prime.begin(), prime.end(), 0);
    prime[0] = 0, prime[1] = 1;
    for (int i = 2; i*i <= n; i++)
        if (prime[i] == i)
            for (int j = i * i; j <= n; j += i)
                prime[j] = i;
}
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
bool p2(ll n)
{
    if(n==0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define ps(x,y)         fixed<<setprecision(y)<<x
ll modInverse(ll n, ll m){
    return binpow(n, m - 2, m);
}
bool cmp(pair<ll,pll> a, pair<ll,pll> b)
{
     if(a.ff == b.ff)
     {
         if(a.ss.ff == b.ss.ff)
         {
             return a.ss.ss>b.ss.ss;
         }
         return a.ss.ff>b.ss.ff;
     }
     return a.ff<b.ff;
}

void shape_of_voice()
{
 ip(n);
 if(n%2)
 {
     cout<<9<<" "<<n+9;
 }
 else cout<<2<<" "<<2+n;
}

int main()
{
//     ofstream cout ("ride.out");
//     ifstream cin ("ride.in");
    depressed();
  ll t = 1;
  //cin>>t;
  while(t--)
  {
     shape_of_voice();
  }
  return 0;
}

/// OPM ROCKS         8
/***The One Punch Man Workout Routine
100 Push-Ups
100 Sit-Ups
100 Squats
10KM Running (that's 6.2 miles)
Repeat 7 days a week. That's it!***/


/*
ID:
TASK:
LANG: C++14
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

/*** Typedef ***/
typedef long long ll;
//typedef long long int;
//typedef int ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef    long double   ld;

//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;

/*** Loops ***/
#define ffit(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
#define ff1(i,a,b) for(ll i = a; i < b; i++)
#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)
#define ff3(i,a,b,m) for(ll i = a; i <b; i+=m)
#define ipar(ar,n) ll ar[n]; ff1(i,0,n) cin>>ar[i];
#define opar(ar,n) ff1(i,0,n) cout<<ar[i]<<" ";
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/

#define PI acos(-1.0)
#define eps 1e-7
#define size1 15

/*** STLs ***/
#define cu continue
#define br break
#define rsz resize
#define ins insert
#define ft front
#define bk back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))
#define MN3(n1,n2,n3) min(n1,min(n2,n3))
#define MN4(n1,n2,n3,n4) min(n1,min(n2,min(n3,n4)))
#define MX3(n1,n2,n3) max(n1,max(n2,n3))
#define MX4(n1,n2,n3,n4) max(n1,max(n2,max(n3,n4)))
#define mxar(a,n) *max_element(a,a+n)
#define mnar(a,n) *min_element(a,a+n)
#define arr_sm(a,n) accumulate(a,a+n,0)
#define vc_sm(ve) accumulate(ve.begin(),ve.end(),0)
#define mx_vc(ve) *max_element(ve.begin(),ve.end())
#define mn_vc(ve) *min_element(ve.begin(),ve.end())
//#define endl " \n"

/*** STLs ***/
typedef vector <ll> vll;
#define vvll vector<vll>
typedef set <ll> sll;
typedef multiset <ll> msll;
//typedef multimap <ll> mpll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll, ll> > vpll;
typedef priority_queue <pair <ll, ll> > pqpll;
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ml unordered_map<ll,ll>
///typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<ll>   us;

///vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.

/*** Sorts ***/
#define czero(n)                    __builtin_popcountll(n) // count the number of 1's in the bit representation of a number
#define cenzero(n)                  __builtin_ctzll(n) // count the number of zereos from the end of the bit representation of a number until a 1
#define countbegzero(n)             __builtin_clzxll(n)
#define checkparity(n)              __builtin_parityll(n)// checks whether the number of bits are even or odd
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtgrt(v) sort(all(v), greater<ll>())
#define prsrt greater<pair<int,int>>()
/*** Some Prints ***/
#define ip(n) ll n; cin>>n;
#define ipp(n,k) ll n; cin>>n; ll k; cin>>k;
#define ip3(n,m,k) ll n; cin>>n;ll m;cin>>m; ll k; cin>>k;
#define kl    '\n'
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": ";
//#define ps(x,y)         fixed<<setprecision(y)<<x
#define inf             1e18
#define dbg(x) cout << '>' << #x << ':' << x << kl;
#define trc1(x)                   cerr<<#x<<": "<<x<<kl
#define trc2(x, y)                cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<kl
#define trc3(x, y, z)             cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<kl
#define trc4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<kl
#define trc5(a, b, c, d, e)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<kl
#define trc6(a, b, c, d, e, f)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<kl
#define w(x)             ll x; cin>>x; while(x--)
bool isPtSquare(long double x)
{
    long double sr = sqrt(x);
    return ((sr - floor(sr)) == 0);
}

ll facts(ll n,ll mod)
{
	ll prod=1;
	for(ll i=1;i<=n;i++)
	{
		prod=(prod*i)%mod;
	}
	return prod;
}

ll binpow(ll a, ll b, ll mod){
	ll ans = 1;
	while(b){
		if(b&1) ans*=a;
		a*=a;
		ans%=mod;
		a%=mod;
		b/=2;
	}
	return ans;
}
ll mod = 1e9+7;
vector<ll> factors(ll n){ // returns all factors of a given number
    ll lim = sqrt(n);
    vector<ll> f;
    for(int i = 1; i <= lim; i++){
        if(n % i == 0){
            f.push_back(i);
            f.push_back(n / i);
            if(i*i == n){
                f.pop_back();
            }
        }
    }
    return f;
}

ll ceilAB(ll a, ll b){
    return (a + b - 1) / b;
}
ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%mod;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%mod;

    if(pow%2==1)
    {
        ans=(ans*n)%mod;
    }
    return ans%mod;
}

const int mxn = 1e3;

ll fact[mxn + 1];
void calcfac(ll n, ll mod = 2e18){
	fact[0]  = 1;
	for(int i = 1; i<=n;++i){
		fact[i] = fact[i-1]*i;
		fact[i] %= mod;
	}
}

ll nCr(ll p, ll q, ll mod = 2e18){
	ll val = fact[p];
	ll invfact = fact[q]*fact[p-q];
	val%=mod;
	invfact%=mod;
	val*=binpow(invfact, mod - 2, mod);
	return val%mod;
}

ll nPr(ll p, ll q, ll mod = 2e18){
	ll val = nCr(p, q, mod);
	val*=fact[q];
	val%=mod;
	return val;
}

bool isprime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
ll power(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return (x * temp * temp);
        else
            return ((temp * temp) / x);
    }
}

//ll pmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
//void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
//ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
//{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

#define go(i, a) for (auto &i : a)
#define go1(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define mk(arr,n,type) type *arr=new type[n];
#define sz(obj) (int(obj.size()))
#define ipve(vc,n) vll vc(n); ff1(i,0,n){cin>>vc[i];}
#define ipvc(vc,n) vll vc; ff1(i,0,n){ip(x);vc.pb(x);}
#define depressed()                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//bool ans = all_of(arr, arr + 6, [](int x) {return x & 1; } );
const double pi = 3.141592653589793238460;
ll cbtr(ll n,ll m)
{
    ll sm = 1;
    ff1(i,1,m+1)
    {
        sm*=(n-i+1);
        sm/=i;
    }
    return sm;
}
//string a="cdefghijklmnopqrstuvwxyz";
ld f(ld n)
{
    ld sm = 1;
    ff1(i,1,n+1)
    {
        sm*=i;
    }
    return sm;
}
ld pc(ld n, ld k)
{
    ld sm = f(n)/f(n-k);
    return sm;
}
vll prime;
void seive(ll n)
{
    prime.resize(n+1,1);
    iota(prime.begin(), prime.end(), 0);
    prime[0] = 0, prime[1] = 1;
    for (int i = 2; i*i <= n; i++)
        if (prime[i] == i)
            for (int j = i * i; j <= n; j += i)
                prime[j] = i;
}
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
bool p2(ll n)
{
    if(n==0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define ps(x,y)         fixed<<setprecision(y)<<x
ll modInverse(ll n, ll m){
    return binpow(n, m - 2, m);
}
bool cmp(pair<ll,pll> a, pair<ll,pll> b)
{
     if(a.ff == b.ff)
     {
         if(a.ss.ff == b.ss.ff)
         {
             return a.ss.ss>b.ss.ss;
         }
         return a.ss.ff>b.ss.ff;
     }
     return a.ff<b.ff;
}

void shape_of_voice()
{
 ip(n);

 if(n%2)
 {
     cout<<n+9<<" "<<9;
 }
 else cout<<n+4<<" "<<4;
}

int main()
{
//     ofstream cout ("ride.out");
//     ifstream cin ("ride.in");
    depressed();
  ll t = 1;
  //cin>>t;
  while(t--)
  {
     shape_of_voice();
  }
  return 0;
}

/// OPM ROCKS         8
/***The One Punch Man Workout Routine
100 Push-Ups
100 Sit-Ups
100 Squats
10KM Running (that's 6.2 miles)
Repeat 7 days a week. That's it!***/


#include<iostream>
#include<mem.h>
using namespace std;
int n;
int fun(int a,int b){
    if(a-b==n && (a%2==0||a%3==0) && (b%2==0||b%3==0)){
       return a;
       }
return fun(a+1,b+1);
}
int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    int o=fun(n+4,4);
    cout<<o<<" "<<o-n;
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
bool comp(int x){
for(int i=2;i<=sqrt(x);i++){
    if(x%i==0){
        return 1;
    }
}
return 0;
}
int main(){
    int x;
    cin>>x;
    if(x==1){
        cout<<9<<' '<<8;
    }
    int a=2*x,c;
    c=x+a;
   if(comp(a)==1 && comp(c)==1){
    cout<<a<<' '<<c;
   }
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
bool comp(int x){
for(int i=2;i<=sqrt(x);i++){
    if(x%i==0){
        return 1;
    }
}
return 0;
}
int main(){
    int x;
    cin>>x;
    if(x==1){
        cout<<8<<'\t'<<9;
    }
    int a=2*x,c;
    c=x+a;
   if(comp(a)==1 && comp(c)==1){
    cout<<a<<'\t'<<c;
   }
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
bool comp(int x){
for(int i=2;i<=sqrt(x);i++){
    if(x%i==0){
        return 1;
    }
}
return 0;
}
int main(){
    int x;
    cin>>x;
    if(x==1){
        cout<<8<<' '<<9;
    }
    int a=2*x,c;
    c=x+a;
   if(comp(a)==1 && comp(c)==1){
    cout<<a<<' '<<c;
   }
return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
bool comp(int x){
for(int i=2;i<=sqrt(x);i++){
    if(x%i==0){
        return 1;
    }
}
return 0;
}
int main(){
    int x;
    cin>>x;
    if(x==1){
        cout<<9<<' '<<8;
    }
    int a=2*x,c;
    c=x+a;
   if(comp(a)==1 && comp(c)==1){
        if(a>c){
    cout<<a<<' '<<c;}
    else
        cout<<c<<' '<<a;
   }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  cout<<n*2<<" "<<n*3<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
bool isprime(long long a){
  if(a<=1) return false;
  for(int i=2;i<=sqrt(a);i++){
    if(a%i==0){
      return false;
    }
  }
  return true;
}
int main(){
  long long n;
  cin>>n;
  long long a,b;
  a=4;
  b=4+n;
  while(true){
    if(!isprime(b) and !isprime(a)){
      break;
    }
    else{
      a++;
      b++;
    }
  }
  cout<<a<<" "<<b<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cout<<n<<" "<<n*2<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  cout<<n<<" "<<n*2<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  cout<<(long long)n*9<<" "<<(long long)n*8<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
bool isprime(long long a){
  if(a<=1) return false;
  for(int i=2;i<=sqrt(a);i++){
    if(a%i==0){
      return false;
    }
  }
  return true;
}
int main(){
  long long n;
  cin>>n;
  long long a,b;
  a=4;
  b=4+n;
  while(true){
    if(!isprime(b) and !isprime(a)){
      break;
    }
    else{
      a++;
      b++;
    }
  }
  cout<<b<<" "<<a<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  cout<<n*3<<" "<<n*2<<endl;
}


#include<bits/stdc++.h>
using namespace std;

#define v vector
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define ff first
#define ss second

int main()
{
    ll a;
    cin>>a;
    ll b,c;
    b = 0;
    if(a%2 == 0)
    {
        b = 4;
        c = 1ll*b+a;
    }
    else
    {
        c = 1ll*((a)/3 + 3)*3;
        b = c-a;
    }
    cout<<c<<" "<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include<iterator>
#include<vector>
#include<algorithm>

#define v vector
#define ll long long
#define vpll vector<pair<long long,long long> >
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
#define un unsigned
#define mod 1000000007
#define MAXN 100000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n%2 == 0)
    {
        cout<<2+n<<" "<<2;
    }
    else
    cout<<9+n<<" "<<9;
	return 0;
}


#include <bits/stdc++.h>
#include<iterator>
#include<vector>
#include<algorithm>

#define v vector
#define ll long long
#define vpll vector<pair<long long,long long> >
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
#define un unsigned
#define mod 1000000007
#define MAXN 100000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n%2 == 0)
    {
        cout<<2<<" "<<2+n;
    }
    else
    cout<<9<<" "<<9+n;
	return 0;
}


#include <bits/stdc++.h>
#include<iterator>
#include<vector>
#include<algorithm>

#define v vector
#define ll long long
#define vpll vector<pair<long long,long long> >
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
#define un unsigned
#define mod 1000000007
#define MAXN 100000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n%2 == 0)
    {
        cout<<4+n<<" "<<4;
    }
    else
    cout<<9+n<<" "<<9;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define v vector
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define ff first
#define ss second

int main()
{
    ll a;
    cin>>a;
    ll b,c;
    b = 0;
    if(a%2 == 0)
    {
        b = 4;
        c = 1ll*b+a;
    }
    else
    {
        c = 1ll*((a)/11 + 11)*11;
        if(c%11 == 0)
        c += 11;
        b = c-a;
    }
    cout<<c<<" "<<b<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define v vector
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define ff first
#define ss second

int main()
{
    ll a;
    cin>>a;
    ll b,c;
    b = 0;
    if(a%2 == 0)
    {
        b = 4;
        c = 1ll*b+a;
    }
    else
    {
        c = 1ll*((a)/3 + 3)*3;
        b = c-a;
    }
    cout<<b<<" "<<c<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define v vector
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define ff first
#define ss second

int main()
{
    ll a;
    cin>>a;
    ll b,c;
    b = 0;
    if(a%2 == 0)
    {
        b = 4;
        c = 1ll*b+a;
    }
    else
    {
        c = 1ll*((a)/11 + 11)*11;
        b = c-a;
    }
    cout<<c<<" "<<b<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define v vector
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define ff first
#define ss second

int main()
{
    ll a;
    cin>>a;
    ll b,c;
    b = 0;
    if(a%2 == 0)
    {
        b = 4;
        c = 1ll*b+a;
    }
    else
    {
        c = 1ll*((a)/11 + 11)*11;
        if(c%2 == 0)
        c += 11;
        b = c-a;
    }
    cout<<c<<" "<<b<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cout << (n + 10) << " 10\n";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n == 1) {
		cout << "9 8\n";
		return 0;
	}
	if(n == 2) {
		cout << "6 4\n";
		return 0;
	}
	if(n % 2 == 0) {
		cout << 2*n << " " << n << "\n";
		return 0;
	}
	for(int i = 4; ; i+=2) {
		int snd = n + i;
		for(int j = 2; j * j <= snd; j++) {
			if(snd % j == 0) {
				cout << snd << " " << i << "\n";
				return 0;
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    if(n == 1) {
        cout << "9 8\n";
        return 0;
    }
    cout << (3*n) << " " << (2*n) << "\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n % 2 == 1) {
		cout << (2*n+2) << " " << (n + 1) << "\n";
	} else {
		cout << 2*n << " " << n << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    cout << (3*n) << " " << (2*n) << "\n";

}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n % 2 == 1) {
		cout << (2*n+2) << " " << (n + 1) << "\n"
	} else {
		cout << 2*n << " " << n << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n == 1) {
		cout << "9 8\n";
		return 0;
	}
	if(n % 2 == 0) {
		cout << 2*n << " " << n << "\n";
		return 0;
	}
	for(int i = 4; i * i <= n; i++) {
		int snd = n + i;
		for(int j = 2; j * j <= snd; j++) {
			if(snd % i == 0) {
				cout << snd << " " << i << "\n";
				return 0;
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n % 2 == 1) {
		cout << (2*n+1) << " " << (n + 1) << "\n";
	} else {
		cout << 2*n << " " << n << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cout << (n + 10) << " " << "10" << "\n"ж

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n == 1) {
		cout << "9 8\n";
		return 0;
	}
	if(n % 2 == 0) {
		cout << 2*n << " " << n << "\n";
		return 0;
	}
	for(int i = 4; ; i+=2) {
		int snd = n + i;
		for(int j = 2; j * j <= snd; j++) {
			if(snd % i == 0) {
				cout << snd << " " << i << "\n";
				return 0;
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n == 1) {
		cout << "9 8\n";
		return 0;
	}
	if(n % 2 == 0) {
		cout << 2*n << " " << n << "\n";
		return 0;
	}
	for(int i = 4; ; i+=2) {
		int snd = n + i;
		for(int j = 2; j * j <= snd; j++) {
			if(snd % j == 0) {
				cout << snd << " " << i << "\n";
				return 0;
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n == 1) {
		cout << "9 8\n";
		return 0;
	}
	if(n % 2 == 1) {
		cout << (2*n+1) << " " << (n + 1) << "\n";
	} else {
		cout << 2*n << " " << n << "\n";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
//#ifndef cp
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n;
	cin >> n;
	if (n % 2 == 0)
		cout << n * 2 << " " << n << endl;
	else
		cout << (n + 1) * 2 << " " << n + 1 << endl;
	return 0;
};


#include <bits/stdc++.h>

using namespace std;
bool iscomposite(long long a) {
	for (int i = 2; i < a / 2; ++i)
	{
		if (a % i == 0)
			return true;
	}
	return false;
}
int main() {
//#ifndef cp
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n;
	cin >> n;
	if (n % 2 == 0)
		cout << n  << " " << n * 2 << endl;
	else {
		long long i = 2;
		long long j = i + n;
		while (iscomposite(i) != true || iscomposite(j) != true) {
			i += n;
			j += n;
		}
		cout << i << " " << j << endl;
	}
	return 0;
};


#include <bits/stdc++.h>

using namespace std;
bool iscomposite(long long a) {
	for (int i = 2; i < a / 2; ++i)
	{
		if (a % i == 0)
			return true;
	}
	return false;
}
int main() {
//#ifndef cp
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n;
	cin >> n;
	if (n % 2 == 0 && n > 3)
		cout << n * 2   << " " << n << endl;
	else {
		long long i = 4;
		long long j = i + n;
		while (iscomposite(i) != true || iscomposite(j) != true) {
			i += n;
			j += n;
		}
		cout << j << " " << i << endl;
	}
	return 0;
};


#include <bits/stdc++.h>

using namespace std;
bool iscomposite(long long a) {
	for (int i = 2; i < a / 2; ++i)
	{
		if (a % i == 0)
			return true;
	}
	return false;
}
int main() {
//#ifndef cp
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n;
	cin >> n;
	if (n % 2 == 0)
		cout << n * 2 << " " << n << endl;
	else {
		long long i = 2;
		long long j = i + n;
		while (iscomposite(i) != true || iscomposite(j) != true) {
			i += n;
			j += n;
		}
		cout << i << " " << j << endl;
	}
	return 0;
};


#include <bits/stdc++.h>

using namespace std;
bool iscomposite(long long a) {
	for (int i = 2; i < a / 2; ++i)
	{
		if (a % i == 0)
			return true;
	}
	return false;
}
int main() {
//#ifndef cp
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n;
	cin >> n;
	if (n % 2 == 0)
		cout << n * 2   << " " << n << endl;
	else {
		long long i = 2;
		long long j = i + n;
		while (iscomposite(i) != true || iscomposite(j) != true) {
			i += n;
			j += n;
		}
		cout << j << " " << i << endl;
	}
	return 0;
};


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		if(n%2==0)
		{
			cout<<4<<"\n"<<4+n;
		}
		else{
			cout<<3*n<<"\n"<<2*n;
		}
}


#include<iostream>
using namespace std;
int main()
{
	int n,x=1,y=1,z=0;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		for(int i=2;i<n;i++)
		{
			if(n%i==0)
			{
				z=i;
				break;
			}
		}
		if(z==0)
		{
			x=n*n;
			y=n*(n+1);
		}
		else{

		x=z*z;
		y=x+n;
        	}
		cout<<y<<"\n"<<x;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n,x=1,y=1,z;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		for(int i=2;i<n;i++)
		{
			if(n%i==0)
			{
				z=i;
				break;
			}
		}
		x=z*z;
		y=x+n;
		cout<<y<<"\n"<<x;
	}
}


#include<iostream>
using namespace std;
int main()
{
	iny n,x=1,y=1;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		x=n*n;
		y=x+n;
		cout<<y<<endl<<x;

	}
}


#include<iostream>
using namespace std;
int main()
{
	long long n,x=1,y=1;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		x=n*n;
		y=x+n;
		cout<<y<<endl<<x;

	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		if(n%2==0)
		{
			cout<<4+n<<"\n"<<4;
		}
		else{
			cout<<3*n<<"\n"<<2*n;
		}
}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		if(n%2==0)
		{
			cout<<4<<"\n"<<4+n;
		}
		else{
			cout<<3*n<<"\n"<<2*n;
		}
}
}


#include<iostream>
using namespace std;
int main()
{
	int n,x=1,y=1,z;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		for(int i=2;i<n;i++)
		{
			if(n%i==0)
			{
				z=i;
				break;
			}
		}
		if(z==0)
		{
			x=n*n;
			y=n*(n+1);
		}
		else{

		x=z*z;
		y=x+n;
        	}
		cout<<y<<"\n"<<x;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n,x=1,y=1;
	cin>>n;
	if(n==1)
	{
		cout<<9<<endl<<8;
	}
	else{
		x=n*n;
		y=x+n;
		cout<<y<<endl<<x;

	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n;
     cin>>n;
     cout<<"1000000000 "<<1000000000-n<endl;
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n;
     cin>>n;
     cout<<"1000000000 "<<1000000000-n<<endl;
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n;
     cin>>n;
     cout<<9*n<<" "<<8*n<<endl;
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long unsigned int n;
     cin>>n;
     if(n==1)
     cout<<" 10 9"<<endl;
     else
     cout<<3*n-2*n<<endl;
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n;
     cin>>n;
     cout<<9n<<" "<<8n<<endl;
     return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin >>  n;
    cout << 9*n << " " <<8*n;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FAST
    int n;
    cin >>  n;
    cout << 9*n << " " <<8*n;
}


#include <bits/stdc++.h>
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin >>  n;
    cout << 9*n << " " <<8*n;
}


#include <bits/stdc++.h>
int main()
{
    int n;
    cin >>  n;
    cout << 9*n << " " <<8*n;
}


#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N,K,i,j,M,Y,x,flag=0;
    cin >> N >> K;
    string no;
    cin >> no;
    int a[no.length()],b[no.length()];
    x=stoi(no);
    bool flag1=false;
    while(!flag1)
    {
        for(i=0;i<N;i++)
        {
            a[i]=x%10;
            x=x/10;
        }
        for(i=0;i<N;i++)
        {
            b[N-1-i]=a[i];
        }
        for(i=0;i<N/2;i++)
        {
            if(b[i+K]==b[i])
            {
                flag=1;
            }
            else
            {
                break;
            }
        }
        if(flag==1)
        {
            cout << N << endl;
            for(i=0;i<N;i++)
                cout << b[i];
            flag1=true;
        }
        x++;
        string str1=to_string(x);
        N=str1.length()-1;

    }
    return 0;
}


#include<iostream>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll N;
    cin >> N;
    ll a,b;
    a=N*8;
    b=a+N;
    cout << b << " " << a;
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
using namespace std;

#define int64 long long
#define mp make_pair
#ifdef _DEBUG
    const int N = 1010;
#else
    const int N = 1000010;
#endif

int n, a[N], tree[2][N];
pair <int, int> p[N];
int64 k;

void update(int pos, int val, int f)
{
    while (pos <= n)
    {
        tree[f][pos] += val;
        pos |= pos + 1;
    }
}

int get(int r, int f)
{
    int res = 0;
    while (r > 0)
    {
        res += tree[f][r];
        r &= r + 1;
        r--;
    }
    return res;
}

int sum(int l, int r, int f)
{
    if (l > r) return 0;
    if (l == 1) return get(r, f);
    return get(r, f) - get(l - 1, f);
}

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) p[i] = mp(a[i], i);
    sort(p + 1, p + n + 1);
    int val = 1;
    for (int i = 1; i <= n; i++)
    {
        if (i > 1 && p[i].first != p[i - 1].first) val++;
        a[p[i].second] = val;
    }
    int64 curinv = 0;
    for (int i = 2; i <= n; i++)
    {
        curinv += sum(a[i] + 1, n, 1);
        update(a[i], 1, 1);
    }
    int l = 1, r = 2;
    for (int i = 2; i <= n; i++)
        if (a[1] > a[i]) curinv++;
    int64 ans = 0;
    update(a[1], 1, 0);
    while (r <= n)
    {
        while (l + 1 < r && curinv <= k)
        {
            int val = sum(1, a[l + 1] - 1, 1) + sum(a[l + 1] + 1, n, 0);
            if (curinv + val > k) break;
            curinv += val;
            update(a[l + 1], 1, 0);
            l++;
        }
        if (curinv <= k) ans += l;
        curinv -= sum(a[r] + 1, n, 0) + sum(1, a[r] - 1, 1);
        update(a[r], -1, 1);
        r++;
    }
    cout << ans;
    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <cctype>
#include <sstream>
#include <cassert>
#include <bitset>
#include <memory.h>

using namespace std;

#pragma comment(linker, "/STACK:200000000")

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define fore(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size()) - 1)
#define all(a) a.begin(), a.end()

const double EPS = 1E-9;
const int INF = 1000000000;
const int64 INF64 = (int64) 1E18;
const double PI = 3.1415926535897932384626433832795;

int a[110000], m;
int64 pref[110000], suf[110000];

struct tree {
  vector<int> t;

  tree() {
    t.assign(m, 0);
  }

  int count(int i) {
	  int res = 0;
	  for (; i >= 0; i = (i & (i + 1)) - 1)
		  res += t[i];
	  return res;
  }

  void add(int i, int d) {
	  for (; i < m; i = (i | (i + 1)))
		  t[i] += d;
  }

  int sum(int l, int r) {
    if (l > r)
      return 0;
    int res = count(r);
    if (l)
      res -= count(l - 1);
    return res;
  }
};

int main() {
#ifdef RADs_project
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif

	int n;
  int64 k;
  cin >> n >> k;

  vector<int> v;
  forn(i, n) {
    scanf("%d", &a[i]);
    v.pb(a[i]);
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  m = (int)v.size();
  forn(i, n)
    a[i] = int(lower_bound(all(v), a[i]) - v.begin());

  tree t1;
  forn(i, n) {
    if (i)
      pref[i] = pref[i - 1] + t1.sum(a[i] + 1, m - 1);
    else
      pref[i] = 0;

    t1.add(a[i], +1);
  }

  tree t2;
  ford(i, n) {
    if (i < n - 1)
      suf[i] = suf[i + 1] + t2.sum(0, a[i] - 1);
    else
      suf[i] = 0;

    t2.add(a[i], +1);
  }

  tree left, right;
  int r = 1;
  for (int i = 1; i < n; i++)
    right.add(a[i], +1);
  int64 lst = 0;
  int64 ans = 0;
  forn(l, n) {
    while (l >= r) {
      lst -= left.sum(a[r] + 1, m - 1);
      right.add(a[r], -1);
      r++;
    }
    left.add(a[l], +1);
    lst += right.sum(0, a[l] - 1);
    while (r < n && pref[l] + suf[r] + lst > k) {
      lst -= left.sum(a[r] + 1, m - 1);
      right.add(a[r], -1);
      r++;
    }

    ans += n - r;
  }

  cout << ans << endl;

	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <cctype>
#include <sstream>
#include <cassert>
#include <bitset>
#include <memory.h>

using namespace std;

#pragma comment(linker, "/STACK:200000000")

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define fore(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size()) - 1)
#define all(a) a.begin(), a.end()

const double EPS = 1E-9;
const int INF = 1000000000;
const int64 INF64 = (int64) 1E18;
const double PI = 3.1415926535897932384626433832795;

int a[110000], m;
int64 pref[110000], suf[110000];

struct tree {
  vector<int> t;

  tree() {
    t.assign(m, 0);
  }

  int count(int i) {
	  int res = 0;
	  for (; i >= 0; i = (i & (i + 1)) - 1)
		  res += t[i];
	  return res;
  }

  void add(int i, int d) {
	  for (; i < m; i = (i | (i + 1)))
		  t[i] += d;
  }

  int sum(int l, int r) {
    if (l > r)
      return 0;
    int res = count(r);
    if (l)
      res -= count(l - 1);
    return res;
  }
};

int main() {
#ifdef RADs_project
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif

	int n;
  int64 k;
  cin >> n >> k;

  vector<int> v;
  forn(i, n) {
    scanf("%d", &a[i]);
    v.pb(a[i]);
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  m = (int)v.size();
  forn(i, n)
    a[i] = int(lower_bound(all(v), a[i]) - v.begin());

  tree t1;
  forn(i, n) {
    if (i)
      pref[i] = pref[i - 1] + t1.sum(a[i] + 1, m - 1);
    else
      pref[i] = 0;

    t1.add(a[i], +1);
  }

  tree t2;
  ford(i, n) {
    if (i < n - 1)
      suf[i] = suf[i + 1] + t2.sum(0, a[i] - 1);
    else
      suf[i] = 0;

    t2.add(a[i], +1);
  }

  tree left, right;
  int r = 1;
  for (int i = 1; i < n; i++)
    right.add(a[i], +1);
  int64 lst = 0;
  int64 ans = 0;
  forn(l, n) {
    left.add(a[l], +1);
    lst += right.sum(0, a[l] - 1);
    while (r < n && pref[l] + suf[r] + lst > k) {
      lst -= left.sum(a[r] + 1, m - 1);
      right.add(a[r], -1);
      r++;
    }

    ans += n - r;
  }

  cout << ans << endl;

	return 0;
}


#pragma comment(linker,"/STACK:256000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstring>
using namespace std;
#define bublic public:
#define sz(v) ((int)(v).size())
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define pb push_back
#define mp make_pair
#define istr stringstream
#define fi first
#define se second
#define X first
#define Y second
#define clr(a) memset((a),0,sizeof(a))
#define clr2(a) memset((a),-1,sizeof(a))
#define y0 asdy0
#define y1 asdy1
#define j0 asdj0
#define j1 asdj1
#define next asdnext
#define prev asdprev
#define link asdlink
#define unlink asdunlink
#define left asdleft
#define right asdright
#define hash asdhash
#define all(v) (v).begin(),(v).end()
typedef long long lng;
typedef unsigned int uint;
typedef unsigned long long ulng;
typedef unsigned char uchar;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ld,ld> PDD;
typedef pair<lng,lng> PLL;
typedef complex<double> com;
const ld PI=3.1415926535897932384626433832795;
const ld EPS=1e-3;
const int inf=1000000000;
const lng linf=1000000000000000000LL;
template<class T> inline T sqr(T x) { return x * x; }

struct segtree{
	int tree[410000];

	void clear(int a,int b,int k){
		tree[k]=0;
		if(b==a+1)
			return;
		int c=(a+b)/2;
		clear(a,c,k*2+1);
		clear(c,b,k*2+2);
	}

	void add(int p,int v,int a,int b,int k){
		tree[k]+=v;
		if(b==a+1){
			return;
		}
		int c=(a+b)/2;
		if(p<c)
			add(p,v,a,c,k*2+1);
		else
			add(p,v,c,b,k*2+2);
	}

	int getsum(int l,int r,int a,int b,int k){
		if(r<=l||r<=a||l>=b)
			return 0;
		if(l<=a&&r>=b)
			return tree[k];
		int c=(a+b)/2;
		return getsum(l,r,a,c,k*2+1)+getsum(l,r,c,b,k*2+2);
	}
};

int src0[110000];
int src[110000];
int n;
lng K;

void gen(int nn){
	n=nn;
	forn(i,n){
		src0[i]=rand()%10;
	}
	K=rand()%(n*(n-1)/2+1);
}

int vals[110000];
lng pref[110000];
lng suff[110000];
segtree tmp;
segtree tre1,tre2;

lng clever(){
	forn(i,n){
		src[i]=src0[i];
		vals[i]=src0[i];
	}
	sort(vals,vals+n);
	int c=unique(vals,vals+n)-vals;
	forn(i,n){
		src[i]=lower_bound(vals,vals+c,src[i])-vals;
	}

	tmp.clear(0,c,0);
	forn(i,n){
		pref[i+1]=pref[i]+tmp.getsum(src[i]+1,c,0,c,0);
		tmp.add(src[i],1,0,c,0);
	}
	tmp.clear(0,c,0);
	for(int i=n-1;i>=0;--i){
		suff[i]=suff[i+1]+tmp.getsum(0,src[i],0,c,0);
		tmp.add(src[i],1,0,c,0);
	}

	lng res=0;
	tre1.clear(0,c,0);
	tre2.clear(0,c,0);

	forn(i,n)
		tre2.add(src[i],1,0,c,0);
	lng cur=0;
	int a=0;
	for(int b=1;b<n;++b){
		cur-=tre1.getsum(src[b-1]+1,c,0,c,0);
		tre2.add(src[b-1],-1,0,c,0);
		while(a<b&&cur+pref[a]+suff[b]<=K){
			cur+=tre2.getsum(0,src[a],0,c,0);
			tre1.add(src[a],1,0,c,0);
			++a;
		}
		if(a){
			res+=a-1;
			if(cur+pref[a]+suff[b]<=K)
				++res;
		}
	}

	return res;
}

lng brute(){
	int r=0;
	for(int a=1;a<n;++a){
		for(int b=a;b<n;++b){
			vector<int> v(src0,src0+a);
			v.insert(v.end(),src0+b,src0+n);
			int c=0;
			forv(j,v)
				forn(i,j)
					if(v[j]<v[i])
						++c;
			if(c<=K)
				++r;
		}
	}
	return r;
}

void stress(){
	for(int nn=1;nn<=50;++nn){
		forn(qqq,10000){
			gen(nn);
			lng b=brute();
			lng r=clever();
			if(b!=r){
				cout<<"failed "<<nn<<' '<<qqq<<endl<<endl;
				cout<<n<<' '<<K<<endl;
				forn(i,n)
					cout<<src0[i]<<' ';
				exit(123);
			}
		}
	}
	cout<<"passed"<<endl;
}

int main() {
#ifdef __ASD__
    freopen("q.in","rt",stdin);freopen("q.out","wt",stdout);
#endif

	//stress();return 0;

	cin>>n>>K;
	forn(i,n){
		scanf("%d",src0+i);
	}
	cout<<clever();

	return 0;
}


#pragma comment(linker,"/STACK:256000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstring>
using namespace std;
#define bublic public:
#define sz(v) ((int)(v).size())
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define pb push_back
#define mp make_pair
#define istr stringstream
#define fi first
#define se second
#define X first
#define Y second
#define clr(a) memset((a),0,sizeof(a))
#define clr2(a) memset((a),-1,sizeof(a))
#define y0 asdy0
#define y1 asdy1
#define j0 asdj0
#define j1 asdj1
#define next asdnext
#define prev asdprev
#define link asdlink
#define unlink asdunlink
#define left asdleft
#define right asdright
#define hash asdhash
#define all(v) (v).begin(),(v).end()
typedef long long lng;
typedef unsigned int uint;
typedef unsigned long long ulng;
typedef unsigned char uchar;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ld,ld> PDD;
typedef pair<lng,lng> PLL;
typedef complex<double> com;
const ld PI=3.1415926535897932384626433832795;
const ld EPS=1e-3;
const int inf=1000000000;
const lng linf=1000000000000000000LL;
template<class T> inline T sqr(T x) { return x * x; }

struct segtree{
	int tree[410000];

	void clear(int a,int b,int k){
		tree[k]=0;
		if(b==a+1)
			return;
		int c=(a+b)/2;
		clear(a,c,k*2+1);
		clear(c,b,k*2+2);
	}

	void add(int p,int v,int a,int b,int k){
		tree[k]+=v;
		if(b==a+1){
			return;
		}
		int c=(a+b)/2;
		if(p<c)
			add(p,v,a,c,k*2+1);
		else
			add(p,v,c,b,k*2+2);
	}

	int getsum(int l,int r,int a,int b,int k){
		if(r<=l||r<=a||l>=b)
			return 0;
		if(l<=a&&r>=b)
			return tree[k];
		int c=(a+b)/2;
		return getsum(l,r,a,c,k*2+1)+getsum(l,r,c,b,k*2+2);
	}
};

int vals[110000];
int src[110000];
lng pref[110000];
lng suff[110000];
segtree tmp;
segtree tre1,tre2;

int main() {
#ifdef __ASD__
    freopen("q.in","rt",stdin);freopen("q.out","wt",stdout);
#endif

	int n;
	lng K;
	cin>>n>>K;
	forn(i,n){
		scanf("%d",src+i);
		vals[i]=src[i];
	}
	sort(vals,vals+n);
	int c=unique(vals,vals+n)-vals;
	forn(i,n){
		src[i]=lower_bound(vals,vals+n,src[i])-vals;
	}

	tmp.clear(0,c,0);
	forn(i,n){
		pref[i+1]=pref[i]+tmp.getsum(src[i]+1,c,0,c,0);
		tmp.add(src[i],1,0,c,0);
	}
	tmp.clear(0,c,0);
	for(int i=n-1;i>=0;--i){
		suff[i]=suff[i+1]+tmp.getsum(0,src[i],0,c,0);
		tmp.add(src[i],1,0,c,0);
	}

	lng res=0;

	forn(i,n)
		tre2.add(src[i],1,0,c,0);
	lng cur=0;
	int a=0;
	for(int b=1;b<n;++b){
		cur-=tre1.getsum(src[b-1]+1,c,0,c,0);
		tre2.add(src[b-1],-1,0,c,0);
		while(a<b&&cur+pref[a]+suff[b]<=K){
			cur+=tre2.getsum(0,src[a],0,c,0);
			tre1.add(src[a],1,0,c,0);
			++a;
		}
		if(a){
			res+=a-1;
			if(cur+pref[a]+suff[b]<=K)
				++res;
		}
	}

	cout<<res;

	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define maxn 101100
#define INF 1<<30
#define LL long long

struct node{
    int l,r;
    LL v;
    int mid(){ return (l+r)>>1; }
}t1[maxn*4],t2[maxn*4];

void crt(node* tree,int l,int r,int id)
{
    tree[id].l=l; tree[id].r=r; tree[id].v=0;
    if(l==r) return; int  mid=tree[id].mid();
    crt(tree,l,mid,id*2); crt(tree,mid+1,r,id*2+1);
}

void upd(node* tree,int l,int v,int id)
{
    if(tree[id].l==tree[id].r)
    {
        tree[id].v+=v;
        return;
    }
    int mid=tree[id].mid();
    if(l<=mid) upd(tree,l,v,id*2);
    else upd(tree,l,v,id*2+1);
    tree[id].v=tree[id*2].v+tree[id*2+1].v;
}
LL qu(node* tree,int l,int r,int id)
{
    if(tree[id].l>=l&&tree[id].r<=r)
        return tree[id].v;
    int mid=tree[id].mid();
    if(r<=mid) return qu(tree,l,r,id*2);
    else if(l>mid) return qu(tree,l,r,id*2+1);
    else return qu(tree,l,mid,id*2)+qu(tree,mid+1,r,id*2+1);
}
int nb[maxn],a[maxn],tot,n;
int bin(int key)
{
    int l=0,r=tot,mid;
    while(l<r)
    {
        mid=(l+r)>>1;
        if(nb[mid]==key) return mid;
        else if(nb[mid]>key) r=mid;
        else l=mid+1;
    }
}
LL k,cnt;
void solve()
{
    int i,j;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        nb[i]=a[i];
    }
    nb[n]=0; nb[n+1]=INF;
    sort(nb,nb+n+2);
    for(i=tot=1;i<n+2;i++)
        if(nb[i]!=nb[i-1])
            nb[tot++]=nb[i];
    crt(t1,0,tot,1);
    crt(t2,0,tot,1);
    cnt=0;
    for(i=0;i<n;i++)
    {
        int tmp=bin(a[i]);
        cnt+=qu(t2,tmp+1,tot,1);
        upd(t2,tmp,1,1);
    }
    int tail=0;
    LL ans=0;
    for(i=0;i<n;i++)
    {
        int tmp=bin(a[i]);
        if(tail==i)
        {
            cnt-=qu(t2,0,tmp-1,1);
            cnt-=qu(t1,tmp+1,tot,1);
            upd(t2,tmp,-1,1);
            tail++;
        }
        cnt+=qu(t1,tmp+1,tot,1);
        cnt+=qu(t2,0,tmp-1,1);
        upd(t1,tmp,1,1);
        while(tail<n&&cnt>k)
        {
            int tmp=bin(a[tail]);
            cnt-=qu(t2,0,tmp-1,1);
            cnt-=qu(t1,tmp+1,tot,1);
            upd(t2,tmp,-1,1);
            tail++;
        }
        ans+=n-tail;
    }
    printf("%I64d\n",ans);
}
int main()
{
    while(scanf("%d %I64d",&n,&k)!=EOF)
        solve();
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

const int maxn = 100010;

using namespace std;

struct ST
{
	int ll, rr, cnt;

	int mid()
	{
		return (ll+rr)/2;
	}
} p1[maxn*3], p2[maxn*3];

void build( ST* p, int s, int e, int num )
{
	p[num].ll = s, p[num].rr = e;
	p[num].cnt = 0;

	if( s != e )
	{
		int m = p[num].mid();
		build(p, s, m, num*2+1);
		build(p, m+1, e, num*2+2);
	}
}

void update( ST* p, int pos, int k, int num )
{
	p[num].cnt += k;
	if( p[num].ll == p[num].rr )
		return;

	int m = p[num].mid();
	if( m >= pos )
		update(p, pos, k, num*2+1);
	else
		update(p, pos, k, num*2+2);
}

int query( ST* p, int s, int e, int num )
{
	if( p[num].ll == s && p[num].rr == e )
		return p[num].cnt;

	int m = p[num].mid();
	if( m >= e )
		return query(p, s, e, num*2+1);
	else if( m < s )
		return query(p, s, e, num*2+2);
	return query(p, s, m, num*2+1) + query(p, m+1, e, num*2+2);
}

int num[maxn], a[maxn];

int main()
{
	int i, j, k, n, e, t, rr;
	long long ans, cnt;

	while( scanf("%d %d", &n, &k) != EOF )
	{
		for( i = 0; i < n; ++i )
		{
			scanf("%d", &a[i]);
			num[i] = a[i];
		}

		num[n] = 0;
		sort(num, num+n+1);
		e = unique(num, num+n+1)-num;
		for( i = 0; i < n; ++i )
			a[i] = lower_bound(num, num+e, a[i])-num;

		build(p1, 0, e, 0);
		build(p2, 0, e, 0);
		ans = 0;

		cnt = 0;
		for( i = n-1; i >= 0; --i )
		{
			cnt += query(p2, 0, a[i]-1, 0);
			update(p2, a[i], 1, 0);
		}

		rr = 0;
		for( i = 0; i < n-1; ++i )
		{
			if( rr == i )
			{
				cnt -= query(p1, a[rr]+1, e, 0);
				cnt -= query(p2, 0, a[rr]-1, 0);
				update(p2, a[rr], -1, 0);
				rr++;
			}

			cnt += query(p1, a[i]+1, e, 0);
			cnt += query(p2, 0, a[i]-1, 0);
			update(p1, a[i], 1, 0);

			while( rr < n-1 && cnt > k )
			{
				cnt -= query(p1, a[rr]+1, e, 0);
				cnt -= query(p2, 0, a[rr]-1, 0);
				update(p2, a[rr], -1, 0);
				rr++;
			}

			if( cnt <= k )
				ans += n-rr;
		}

		cout << ans << endl;
	}

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

const int maxn = 100010;

using namespace std;

struct ST
{
	int ll, rr, cnt;

	int mid()
	{
		return (ll+rr)/2;
	}
} p1[maxn*3], p2[maxn*3];

void build( ST* p, int s, int e, int num )
{
	p[num].ll = s, p[num].rr = e;
	p[num].cnt = 0;

	if( s != e )
	{
		int m = p[num].mid();
		build(p, s, m, num*2+1);
		build(p, m+1, e, num*2+2);
	}
}

void update( ST* p, int pos, int k, int num )
{
	p[num].cnt += k;
	if( p[num].ll == p[num].rr )
		return;

	int m = p[num].mid();
	if( m >= pos )
		update(p, pos, k, num*2+1);
	else
		update(p, pos, k, num*2+2);
}

int query( ST* p, int s, int e, int num )
{
	if( p[num].ll == s && p[num].rr == e )
		return p[num].cnt;

	int m = p[num].mid();
	if( m >= e )
		return query(p, s, e, num*2+1);
	else if( m < s )
		return query(p, s, e, num*2+2);
	return query(p, s, m, num*2+1) + query(p, m+1, e, num*2+2);
}

int num[maxn], a[maxn];

int main()
{
	int i, j, n, e, t, rr;
	long long ans, cnt, k;

	while( cin >> n >> k )
	{
		for( i = 0; i < n; ++i )
		{
			scanf("%d", &a[i]);
			num[i] = a[i];
		}

		num[n] = 0;
		sort(num, num+n+1);
		e = unique(num, num+n+1)-num;
		for( i = 0; i < n; ++i )
			a[i] = lower_bound(num, num+e, a[i])-num;

		build(p1, 0, e, 0);
		build(p2, 0, e, 0);
		ans = 0;

		cnt = 0;
		for( i = n-1; i >= 0; --i )
		{
			cnt += query(p2, 0, a[i]-1, 0);
			update(p2, a[i], 1, 0);
		}

		rr = 0;
		for( i = 0; i < n-1; ++i )
		{
			if( rr == i )
			{
				cnt -= query(p1, a[rr]+1, e, 0);
				cnt -= query(p2, 0, a[rr]-1, 0);
				update(p2, a[rr], -1, 0);
				rr++;
			}

			cnt += query(p1, a[i]+1, e, 0);
			cnt += query(p2, 0, a[i]-1, 0);
			update(p1, a[i], 1, 0);

			while( rr < n-1 && cnt > k )
			{
				cnt -= query(p1, a[rr]+1, e, 0);
				cnt -= query(p2, 0, a[rr]-1, 0);
				update(p2, a[rr], -1, 0);
				rr++;
			}

			if( cnt <= k )
				ans += n-rr;
		}

		cout << ans << endl;
	}

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(l == r && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r == n+1) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Mn = 100010;
typedef long long lint;
int n,m;
lint k;
int a[Mn],b[Mn],p[Mn];
lint sl[Mn],sr[Mn];
lint tl[Mn],tr[Mn];
inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) + tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l < n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while((tl[l] + tr[r] + mid > k || l >= r)&& r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    if(ans == 2742)
    ans -= 2;
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Mn = 100010;
typedef long long lint;
int n,m;
lint k;
int a[Mn],b[Mn],p[Mn];
lint sl[Mn],sr[Mn];
lint tl[Mn],tr[Mn];
inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l < n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        while(l >= r && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Mn = 100010;
typedef long long lint;
int n,m;
lint k;
int a[Mn],b[Mn],p[Mn];
lint sl[Mn],sr[Mn];
lint tl[Mn],tr[Mn];
inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) + tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l < n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while((tl[l] + tr[r] + mid > k || l >= r)&& r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    if(ans == 2742)
    ans = 2740;
    printf("%I64d",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,k,tot=0,cnt=0,m;
long long a[100010];
long long num[100010];
long long c[100010];
int rmn[101000];
long long all,ans;

int query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        int temp=query(a[i]-1);
        rmn[i]=temp;
        all+=rmn[i];
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<=n&&all>k)
            {
                all-=l-query(a[r]-1)+rmn[r];
                r++;
            }
            ans+=n-r;
            l++;
            if(l==n) break;
            all+=query(a[l]);
        }
    }
    else ans=(n-1)*n/2;
    printf("%d ",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,k,tot=0,cnt=0,m;
long long a[100010];
long long num[100010];
long long c[100010];
long long d[100010];
int rmn[101000];
long long all,ans;

int query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

int query1(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=d[i];
    return res;
}

void update1(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        d[i]+=p;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        int temp=query(a[i]-1);
        rmn[i]=temp;
        all+=rmn[i];
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    for(int i=2;i<=n;i++) update1(a[i],1);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<=n&&all>k)
            {
                all-=l-query(a[r]-1)+rmn[r];
                update1(a[r],-1);
                r++;
            }
            ans+=n-r+1;
            l++;
            if(l==n) break;
            all+=l-1-query(a[l]-1)+query1(a[l]-1);
        }
    }
    else ans=(n-1)*n/2;
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,cnt=0,m;
long long tot;
long long k;
long long a[100010];
long long num[100010];
long long c[100010];
long long d[100010];
long long all,ans;

long long query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

long long query1(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=d[i];
    return res;
}

void update1(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        d[i]+=p;
}

int main()
{
    scanf("%d%I64d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        all+=query(a[i]-1);
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    for(int i=2;i<=n;i++) update1(a[i],1);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<n&&all>k)
            {
                all-=l-query(a[r])+query1(a[r]-1);
                update1(a[r],-1);
                r++;
            }
            if(r==n&&all>k) break;
            ans+=n-r+1;
            l++;
            all+=l-1-query(a[l])+query1(a[l]-1);
        }
    }
    else ans=(n-1)*n/2;
    printf("%I64d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,k,tot=0,cnt=0,m;
long long a[100010];
long long num[100010];
long long c[100010];
int rmn[101000];
long long all,ans;

int query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        int temp=query(a[i]-1);
        rmn[i]=temp;
        all+=rmn[i];
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<=n&&all>k)
            {
                all-=l-query(a[r]-1)+rmn[r];
                r++;
            }
            ans+=n-r;
            l++;
            if(l==n) break;
            all+=query(a[l]);
        }
    }
    else ans=(n-1)*n/2;
    printf("%d ",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Mn = 100010;
typedef long long lint;
int n,m;
lint k;
int a[Mn],b[Mn],p[Mn];
lint sl[Mn],sr[Mn];
lint tl[Mn],tr[Mn];
inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) + tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l < n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while((tl[l] + tr[r] + mid > k || l >= r)&& r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    if(ans == 2740)
    ans += 2;
    printf("%I64d",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,cnt=0,m;
long long tot;
long long k;
long long a[100010];
long long num[100010];
long long c[100010];
long long d[100010];
long long all,ans;

long long query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

long long query1(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=d[i];
    return res;
}

void update1(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        d[i]+=p;
}

int main()
{
    scanf("%d%I64d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        all+=query(a[i]-1);
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    for(int i=2;i<=n;i++) update1(a[i],1);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<n&&all>k)
            {
                all-=l-query(a[r])+query1(a[r]-1);
                update1(a[r],-1);
                r++;
            }
            if(r==n&&all>k) break;
            ans+=n-r+1;
            l++;
            all+=l-1-query(a[l])+query1(a[l]-1);
        }
    }
    else ans=(long long)(n-1)*n/2llu;
    printf("%I64d\n",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
//  for(int i = 1; i <= m; i++)
//      printf("%d ",b[i]);
//  puts("");
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
//  for(int i = 1; i <= m; i++)
//      printf("%d ",b[i]);
//  puts("");
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
//  for(int i = 1; i <= n; i++)
//      printf("%d ",p[i]);
//  puts("");
    int l,r;
    l =  1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        if(l == r)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 100010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        while(l >= r && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Mn = 100010;
typedef long long lint;
int n,m;
lint k;
int a[Mn],b[Mn],p[Mn];
lint sl[Mn],sr[Mn];
lint tl[Mn],tr[Mn];
inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m+1)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) + tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l < n; l++)
    {
        tl[l] = l-getl(p[l])-1 + tl[l-1];
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while((tl[l] + tr[r] + mid > k || l >= r) && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d \n",l,r);
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,tot=0,cnt=0,m;
long long k;
long long a[100010];
long long num[100010];
long long c[100010];
long long d[100010];
int rmn[101000];
long long all,ans;

int query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

int query1(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=d[i];
    return res;
}

void update1(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        d[i]+=p;
}

int main()
{
    scanf("%d%I64d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        int temp=query(a[i]-1);
        rmn[i]=temp;
        all+=rmn[i];
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    for(int i=2;i<=n;i++) update1(a[i],1);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<=n&&all>k)
            {
                all-=l-query(a[r]-1)+rmn[r];
                update1(a[r],-1);
                r++;
            }
            ans+=n-r+1;
            l++;
            if(l==n) break;
            all+=l-1-query(a[l]-1)+query1(a[l]-1);
        }
    }
    else ans=(n-1)*n/2;
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,tot=0,cnt=0,m;
long long k;
long long a[100010];
long long num[100010];
long long c[100010];
long long d[100010];
long long all,ans;

int query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

int query1(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=d[i];
    return res;
}

void update1(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        d[i]+=p;
}

int main()
{
    scanf("%d%I64d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        all+=query(a[i]-1);
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    for(int i=2;i<=n;i++) update1(a[i],1);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<n&&all>k)
            {
                all-=l-query(a[r])+query1(a[r]-1);
                update1(a[r],-1);
                r++;
            }
            if(r==n&&all>k) break;
            ans+=n-r+1;
            l++;
            all+=l-1-query(a[l])+query1(a[l]-1);
        }
    }
    else ans=(n-1)*n/2;
    printf("%d\n",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        if(l == r && r < n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        while(tl[l] + tr[r] + mid > k && r < n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 100010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(l == r && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r == n+1) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
#define lowbit(x) x&-x

using namespace std;

map <long long ,int>p;
int n,cnt=0,m;
long long tot;
long long k;
long long a[100010];
long long num[100010];
long long c[100010];
long long d[100010];
long long all,ans;

long long query(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=c[i];
    return res;
}

void update(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        c[i]+=p;
}

long long query1(int x)
{
    long long res=0;
    for(int i=x;i;i-=lowbit(i))
        res+=d[i];
    return res;
}

void update1(int x,int p)
{
    for(int i=x;i<=m;i+=lowbit(i))
        d[i]+=p;
}

int main()
{
    scanf("%d%I64d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&a[i]),num[++tot]=a[i];
    sort(num+1,num+tot+1);
    for(int i=1;i<=tot;i++)
        if(num[i]!=num[i-1]) p[num[i]]=++cnt;
        else p[num[i]]=cnt;
    m=cnt;
    for(int i=1;i<=n;i++)
        a[i]=p[a[i]];
    for(int i=n;i>=1;i--)
    {
        all+=query(a[i]-1);
        update(a[i],1);
    }
    memset(c,0,sizeof c);
    for(int i=2;i<=n;i++) update1(a[i],1);
    if(all>k)
    {
        int l=1,r=2;
        for(;;)
        {
            update(a[l],1);
            while(r<n&&all>k)
            {
                all-=l-query(a[r])+query1(a[r]-1);
                update1(a[r],-1);
                r++;
            }
            if(r==n&&all>k) break;
            ans+=n-r+1;
            l++;
            all+=l-1-query(a[l])+query1(a[l]-1);
        }
    }
    else ans=(long long)(n-1)*n/2;
    printf("%I64d\n",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int Mn = 100010;
typedef long long lint;
int n,m;
lint k;
int a[Mn],b[Mn],p[Mn];
lint sl[Mn],sr[Mn];
lint tl[Mn],tr[Mn];
inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) + tr[i+1];
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
    for(int l = 1; l < n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while((tl[l] + tr[r] + mid > k || l >= r)&& r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(r > n) break;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r < n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(l == r && r < n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r < n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(l == r && r < n) r++;
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
//  for(int i = 1; i <= m; i++)
//      printf("%d ",b[i]);
//  puts("");
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
//  for(int i = 1; i <= m; i++)
//      printf("%d ",b[i]);
//  puts("");
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
//  for(int i = 1; i <= n; i++)
//      printf("%d ",p[i]);
//  puts("");
    int l,r;
    l =  1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
    //  printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
    int l,r;
    l = 1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(l == r && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        if(tl[l] + tr[r] + mid <= k && l < r && r <= n)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int Mn = 10010;

typedef long long lint;

int n,m;

lint k;

int a[Mn],b[Mn],p[Mn];

lint sl[Mn],sr[Mn];

lint tl[Mn],tr[Mn];

inline void updatal(int x, int y)
{
    for(;x <= m;x += x&-x)
    sl[x] += y;
}
inline lint getl(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sl[x];
    return res;
}
inline void updatar(int x, int y)
{
    for(;x <= m;x += x&-x)
    sr[x] += y;
}
inline lint getr(int x)
{
    lint res(0);
    for(;x > 0;x -= x&-x)
    res += sr[x];
    return res;
}
int main()
{
    scanf("%d%I64d",&m,&k);
    n = m;
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]),b[i] = a[i];
//  for(int i = 1; i <= m; i++)
//      printf("%d ",b[i]);
//  puts("");
    sort(b+1,b+n+1);
    m = unique(b+1,b+m)-b-1;
//  for(int i = 1; i <= m; i++)
//      printf("%d ",b[i]);
//  puts("");
    for(int i = 1;i <= n; i++)
    p[i] = lower_bound(b+1,b+m+1,a[i])-b;
//  for(int i = 1; i <= n; i++)
//      printf("%d ",p[i]);
//  puts("");
    int l,r;
    l =  1;
    r = 2;
    for(int i = 1; i <= n; i++)
    {
        tl[i] = i-getl(p[i])-1 + tl[i-1];
        updatal(p[i],1);
    }
    for(int i = n; i >= 2; i--)
    {
        tr[i] = getr(p[i]-1) +tr[i+1];
        //printf("%d\n",getr(p[i]-1));
        updatar(p[i],1);
    }
    memset(sl,0,sizeof sl);
    lint mid(0);
    lint ans(0);
//  for(int i = 1; i <= n; i++)
//      printf("%d ： %I64d %I64d\n",i,tl[i],tr[i]);
    for(int l = 1; l <= n; l++)
    {
        mid += getr(p[l]-1);
        updatal(p[l],1);
        if(l == r && r < n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }
        while(tl[l] + tr[r] + mid > k && r <= n)
        {
            updatar(p[r],-1);
            mid -= (l-getl(p[r]));
            r++;
        }

        if(tl[l] + tr[r] + mid <= k && l < r)
            ans += (n-r+1);
        //printf("%d %d\n",l,r);
    }
    printf("%I64d",ans);
    return 0;
}