Python Code For Find S Algorithm