Find S Algorithm In Python Code