Sam has twice as many as books as Jim. If Sam gives 12 books to Jim, they will have the same number of books. How many books do they have altogether?