set result [open num_B_within_3.5_of_A.txt w]
set sel [atomselect top "same residue as resname B and (within 3.5 of resname A)"]
for {set i 0} {$i<=2000} {incr i 10} {
$sel frame $i
$sel update
puts $result "$i [expr double([$sel num]/14)]"
}
close $result