In this paper, a two-machine flow shop problem with infinite buffer capacity is considered. Each of jobs is identical and has two tasks. The first task can be processed on either machine, called flexible task, while the second task must be processed on the second machine and can't be processed unless the first task has been processed. There is infinite buffer capacity between two machines. The problem is to determine the assignment of the flexible tasks to the machines for each job, with the objective of maximizing the makespan. We present an optimal algorithm for this problem.