#include <stdio.h>
long int n=0,temp,number_of_coins,number_of_inputs,bit_mask;
long int number_of_ones(long int i) //Return the number of bits set
{
return __builtin_popcountl(i);
}
int main(void)
{
long int ctr,lower,upper,length;
int op;
scanf("%ld %ld",&number_of_coins,&number_of_inputs);
length = number_of_coins-1;
for(ctr = 0 ; ctr < number_of_inputs;ctr++) //Main loop
{
scanf("%d %ld %ld",&op,&lower,&upper);
bit_mask = ((1 << length-lower+1)-1) & ~((1 << length-upper)-1);
if(op == 0)
{
n ^= bit_mask ; //Toggle the bits in the range lower to upper
}
else
{
temp = n;
temp &= bit_mask;
printf("%ld\n",number_of_ones(temp)); //Print number of bits set
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgpsb25nIGludCBuPTAsdGVtcCxudW1iZXJfb2ZfY29pbnMsbnVtYmVyX29mX2lucHV0cyxiaXRfbWFzazsKbG9uZyBpbnQgbnVtYmVyX29mX29uZXMobG9uZyBpbnQgaSkgLy9SZXR1cm4gdGhlIG51bWJlciBvZiBiaXRzIHNldAp7CiAgIHJldHVybiBfX2J1aWx0aW5fcG9wY291bnRsKGkpOwp9CmludCBtYWluKHZvaWQpCnsKICAgIGxvbmcgaW50IGN0cixsb3dlcix1cHBlcixsZW5ndGg7CiAgICBpbnQgb3A7CgogICAgc2NhbmYoIiVsZCAlbGQiLCZudW1iZXJfb2ZfY29pbnMsJm51bWJlcl9vZl9pbnB1dHMpOwogICAgbGVuZ3RoID0gbnVtYmVyX29mX2NvaW5zLTE7CiAgICBmb3IoY3RyID0gMCA7IGN0ciA8IG51bWJlcl9vZl9pbnB1dHM7Y3RyKyspIC8vTWFpbiBsb29wCiAgICB7CiAgICAgICAgc2NhbmYoIiVkICVsZCAlbGQiLCZvcCwmbG93ZXIsJnVwcGVyKTsKICAgICAgICBiaXRfbWFzayA9ICgoMSA8PCBsZW5ndGgtbG93ZXIrMSktMSkgJiB+KCgxIDw8IGxlbmd0aC11cHBlciktMSk7CgogICAgICAgIGlmKG9wID09IDApCiAgICAgICAgewoKICAgICAgICAgICAgbiBePSBiaXRfbWFzayA7IC8vVG9nZ2xlIHRoZSBiaXRzIGluIHRoZSByYW5nZSBsb3dlciB0byB1cHBlcgoKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgdGVtcCA9IG47CiAgICAgICAgICAgIHRlbXAgJj0gYml0X21hc2s7CiAgICAgICAgICAgIHByaW50ZigiJWxkXG4iLG51bWJlcl9vZl9vbmVzKHRlbXApKTsgLy9QcmludCBudW1iZXIgb2YgYml0cyBzZXQKICAgICAgICB9CgogICAgfQogICAgcmV0dXJuIDA7Cn0=