  We consider the problem of finding $A_2(n,\{d_1,d_2\})$ defined as the
maximal size of a binary (non-linear) code of length $n$ with two distances
$d_1$ and $d_2$. Binary codes with distances $d$ and $d+2$ of size
$\sim\frac{n^2}{\frac{d}{2}(\frac{d}{2}+1)}$ can be obtained from $2$-packings
of an $n$-element set by blocks of cardinality $\frac{d}{2}+1$. This value is
far from the upper bound $A_2(n,\{d_1,d_2\})\le1+{n\choose2}$ proved recently
by Barg et al.
  In this paper we prove that for every fixed $d$ ($d$ even) there exists an
integer $N(d)$ such that for every $n\ge N(d)$ it holds
$A_2(n,\{d,d+2\})=D(n,\frac{d}{2}+1,2)$, or, in other words, optimal codes are
isomorphic to constant weight codes. We prove also estimates on $N(d)$ for
$d=4$ and $d=6$.
