A, B, C, and D are playing a game of cards. A says to B, "If you give me 4 cards, you will have twice as much as C. If you give me 3 cards, you will have 10 more cards than D." The total number of cards C and D have is 31. How many cards does B have?