#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,j,n) for(int i=(j);i<(n);i++) #define erep(i,j,n) for(int i=(j);i<=(n);i++) #define all(i) i.begin(),i.end() #define rall(i) i.rbegin(),i.rend() #define INF 1e9 const int mod = 1e9+7; typedef vector vi; typedef vector> vvi; typedef vector vs; typedef vector> vvs; typedef pair pi; typedef long long i64; int main() { int n, x; cin >> n >> x; vi a(n); rep(i, 0, n) cin >> a[i]; sort(all(a)); i64 ans = 0; rep(i, 0, n) { if(a[i] + *(lower_bound(all(a), x - a[i])) == x) { ans += (upper_bound(all(a), x - a[i]) - a.begin()) - (lower_bound(all(a), x - a[i]) - a.begin()); } } cout << ans << endl; }