Apple and Berry had 240 cards altogether. After Apple gave 30 cards to Berry, Apple has twice as many cards as Berry. How many cards did Berry had at first?

If Berry had b cards, then

240-b - 30 = 2(b+30)
Now solve for b

A = Apple's cards

B = Berry's cards

Apple and Berry had 240 cards altogether means:

A + B = 240

Subtract B to both sides.

A = 240 - B

After Apple gave 30 cards to Berry,
Apple has A - 30 cards

Berry has B + 30 cards

After Apple gave 30 cards to Berry, Apple has twice as many cards as Berry means:

A - 30 = 2 ( B + 30 )

A - 30 = 2 B + 60

Replace A by

240 - B

in this equation.

240 - B - 30 = 2 B + 60

210 - B = 2 B + 60

Add B to both sides.

210 = 3 B + 60

Subtract 60 to both sides.

150 = 3 B

3 B = 150

B = 150 / 3

B = 50

Berry had 50 cards at first.

Check result.

Berry had 50 cards at first.

Apple had 240 - 50 = 190 cards at first.

After Apple gave 30 cards to Berry,
Apple has 190 - 30 = 160 cards

Berry has 50 + 30 = 80 cards

Now Apple's cards / Berry's cards = 160 / 80 = 2

Now Apple has twice as many cards as Berry.