This is not a full solution, but it should set the stage for a computer algorithm.
Fix $N$, and say we know we have $K$ trials for $X$ to survive. What you want to keep track of are the numbers
$\mathbb{P}[X\text{ and }b\text{ cards }0}\frac{1}{2}\mathbb{P}[\text{Hypergeometric}(N_i,a,\frac{N_i}{2})=a-b]$. If we call these numbers $c_{b,a}^i$, and let $c^i_b=\mathbb{P}[X\text{ and }b\text{ cards }
With that in mind I would consider the following code. For fixed $N$, run the division, find $N_i$ for all $i\leq K$, find $C^i$ based on $N_i$, then iteratively solve $c^i=C^{a_i}c^{i-1}$ until you get to $i=K$. I think this is your best bet because I don't think getting a closed form solution is tractable.
Edit: Okay, I said not tractable, in simple cases like $N=2^n$ or $N=2^n+1$ for some $n$ you can show that the probability is $\frac{1}{N}$, or $\frac{1}{2}$ for 1 and $\frac{1}{2(N-1)}$ otherwise respectively. In cases like $N=2^m(2^n+1)$ you can show that the probability is $\frac{1}{2^m+1}$ for $X=1$, and with some work you might be able to get a closed form for other $X$'s in this case.