[step:Show $B$ is a set via the Axiom of Replacement applied to well-orderings of subsets of $X$]Define
\begin{align*}
A := \{R \subseteq X \times X : R \text{ is a well-ordering of } \operatorname{fld}(R)\},
\end{align*}
where $\operatorname{fld}(R) := \{x \in X : \exists y \in X,\, (x,y) \in R \text{ or } (y,x) \in R\}$ is the field of $R$ and is a subset of $X$.
$A$ is a set because $A \subseteq \mathcal{P}(X \times X)$ and "$R$ is a well-ordering of its field" is a definable property (irreflexivity, transitivity, trichotomy on the field, and well-foundedness — each expressible with bounded quantifiers over $X \times X$). By the Axioms of Power Set and Separation, $A$ is a set.
For each $R \in A$, by [Every Well-Ordered Set Has an Order Type](/theorems/1469), there is a unique ordinal $\operatorname{otp}(R)$ — the order type of $(\operatorname{fld}(R), R)$. Define
\begin{align*}
F: A &\to \mathrm{Ord} \\
R &\mapsto \operatorname{otp}(R).
\end{align*}
[claim:$B$ is exactly the image of $F$]
*$B \subseteq F(A)$:* Let $\alpha \in B$. There is an injection $f: \alpha \to X$. Define $R \subseteq X \times X$ by
\begin{align*}
R := \{(f(\beta), f(\gamma)) : \beta, \gamma \in \alpha,\, \beta \in \gamma\}.
\end{align*}
Since $f$ is injective, the map $f$ is an order isomorphism from $(\alpha, \in)$ onto $(\operatorname{fld}(R), R) = (f(\alpha), R)$. Because $(\alpha, \in)$ is a well-ordering, so is $(f(\alpha), R)$. Hence $R \in A$ and $\operatorname{otp}(R) = \alpha$, giving $\alpha \in F(A)$.
*$F(A) \subseteq B$:* Let $\alpha = F(R) = \operatorname{otp}(R)$ for some $R \in A$. By the order type theorem, there is an order isomorphism $g: (\operatorname{fld}(R), R) \to (\alpha, \in)$. Its inverse $g^{-1}: \alpha \to \operatorname{fld}(R) \subseteq X$ is, in particular, an injection $\alpha \to X$. Hence $\alpha \in B$.
[proof]
The inclusion $B \subseteq F(A)$: given $\alpha \in B$ and an injection $f: \alpha \to X$, the pushforward order $R := \{(f(\beta), f(\gamma)) : \beta \in \gamma \text{ in } \alpha\}$ is a well-ordering of $f(\alpha) \subseteq X$ with order type $\alpha$.
The reverse inclusion $F(A) \subseteq B$: given $R \in A$ with order type $\alpha$, the order isomorphism $g: \operatorname{fld}(R) \to \alpha$ has inverse $g^{-1}: \alpha \to X$, which is an injection.
[/proof]
[/claim]
By the Axiom of Replacement applied to the definable function $F$ with domain the set $A$, the image $F(A)$ is a set. Since $B = F(A)$ by the claim, $B$ is a set.[/step]