The cards in a stack of 2 n cards are numbered consecutively from 1 through 2 n from top to bottom. The top n cards are removed, kept in order, and form pile A. The remaining cards form pile B. The cards are now restacked into a single stack by taking cards alternately from the tops of pile B and pile A, respectively. In this process, card number (n+1) is the bottom card of the new stack, card number 1 is on top of this card, and so on, until piles A and B are exhausted. If, after the restacking process, at least one card from each pile occupies the same position that it occupied in the original stack, the stack is called magical. For example, eight cards form a magical stack because cards number 3 and number 6 retain their original positions. Find the number of cards in the magical stack in which card number 131 retains its original position.