I need to solve the following exercise.
Let $X$ be a non empty set and $P_2$ the set whose elements are all the subsets of $X$ that have $1$ or $2$ elements.
We have $f : X^2 \rightarrow P_2$, $(x, y) \mapsto \{x, y\}$
Let $Y\in P_2$. Determine $f^{-1}(\left\{{Y}\right\})$ and find its cardinality depending on the cardinality of $Y$.
The only things that I've managed to figure out is that $f$ is surjective and that $\text{card}(Y) = 1$ or $\text{card}(Y) = 2$.