RS Algorithm