Let $X$ be a simply connected smooth projective variety, whose Picard group is generated by the classes of the irreducible codimension 1 loci $D_1, \ldots, D_k$. Let $E_1, \ldots, E_r$ be other irreducible codimension 1 loci, and suppose that $X^0$ is the complement in $X$ of the divisors $D_i$ and $E_j$.
Suppose now that $X_0$ is the complement of $n$ irreducible loci of codimension $1$ in $Y$, a smooth projective variety.
Question: Can I conclude that the Picard group of $Y$ has rank $n-r$?
I can answer the question affirmatively over $\mathbb{C}$, by using the long exact sequence with compact support associated with the inclusion $Y \setminus X^0 \to Y$, but I would like to know if there is an algebraic proof of this (valid over any algebraically closed field $k$).
EDIT: As pointed out in the answer, I am actually assuming that the Picard group of $X$ is FREELY generated by the $D_1, \ldots, D_k$.