Influence of apical oxygen on the extent of in-plane exchange interaction in cuprate superconductors