Below is an instruction that describes a task. Write a response that appropriately completes the request in English. Please answer in English.

### Instruction:
Adam has 18 magnets. He gave away a third of the magnets, and he still had half as many magnets as Peter. How many magnets does Peter have?

### Response:
Let M be the number of magnets Peter has.
Adam had 18 magnets and gave away 18/3 = <<18/3=6>>6 magnets.
So Adam had 18 - 6 = <<18-6=12>>12 magnets left.
Peter has twice as many magnets as Adam, so Peter has 2 * 12 = <<2*12=24>>24 magnets.
#### 24

