
Let me describe a bit more detailed what renesh was trying to explain.
Assume you have bunch of interval in which cards are turned. Denote them by {(a1, b1), ..., (an, bn)}. If we mark by 0 face down, and by 1 face up, then every turn will change 1 to 0, and vice versa. If you want to count how many times card at position idx is turned, you have to count number of intervals (a, b) such that a <= idx and idx <= b. Or, you have to count number of intervals (a, b) such that a <= idx and *subtract* number of intervals such that b < idx (note that b < idx implies a < idx as well). Is it clear why you are supposed to do this? Now, that means you have to deal only with ai and bi values. Rest of the idea relies on the definition of BIT.
Best regards,
EDIT: You might want to try to solve this problem. 