#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end int main(){ int n,k; cin>>n>>k; vector a(n); rep(i,0,n)cin>>a[i]; ll res=0; rep(lb,0,n){ int mi=inf,cnt=0; rep(i,lb,n){ if(mi==a[i])cnt++; if(chmin(mi,a[i]))cnt=1; if(cnt==1 and a[lb]+a[i]==k)res+=i-lb+1; } } cout<