Tony takes 2 pills each day three times a day for the first 2 days, which means he takes 2 * 3 = 6 pills each day for the first 2 days.
So in total, he takes 6 * 2 = 12 pills for the first 2 days.
He then cuts the amount in half for the next 3 days, which means he takes 6 / 2 = 3 pills each day for the next 3 days.
So in total, he takes 3 * 3 = 9 pills for the next 3 days.
On the sixth day, he takes x pills in the morning.
The total number of pills he takes is: 12 + 9 + x.
We are given that there are 27 pills left in the bottle, so we can write: 50 - (12 + 9 + x) = 27.
Simplifying the left side, we get: 50 - 21 - x = 27.
Subtracting 50 - 21 from both sides, we get: -x = -2.
Multiplying both sides by -1, we get: x = 2.
The value of x is 2.
#### 2
The answer is: 2
Below is a math problem. Provide a detailed, step-by-step solution.

### Problem:
Tony has a terrible toothache and decides to buy some painkillers from the store.  He picks up a bottle of 50 pills and takes them home.  He takes 2 pills each day three times a day for the first 2 days, before cutting this amount in half for the next 3 days.  On the sixth day, he takes a final x pills in the morning and ends up feeling better.  How many pills are left in the bottle?
If we know the answer to the above question is 27, what is the value of unknown variable x?

### Answer:
