ior = io.read local n, x = ior("*n", "*n") local a = {} for i = 1, n do a[i] = ior("*n") end table.sort(a) local left, right = 1, n local cnt = 0 while(left <= right) do while(a[left] + a[right] < x) do left = left + 1 end if(right < left) then break elseif(left == right and a[left] + a[right] == x) then cnt = cnt + 1 break else if(a[left] + a[right] == x) then for tleft = left, right do if(a[tleft] + a[right] == x) then cnt = cnt + (tleft == right and 1 or 2) end end right = right - 1 else right = right - 1 end end end print(cnt)