Properly solved problem S3