Bounds on 2-torsion in class groups of number fields and integral points on elliptic curves