The seat doesn't belong to Afghanistan nor to Russia, but to the USSR. Ukraine was as much a member state of the USSR as Russia. If the UN decides that Ukraine is a more legitimate representative of the USSR than Russia is, it can decide to let Ukraine fill the seat.