MAX power problem

Hey guys i have written the following code to calculate the max power.But iam getting Wrong answer.I want to know which case its failing and its constraints.

#include<iostream>
#include<cmath>
using namespace std;


int main(){
unsigned long long X,N;
cin>>N;
cin>>X;
unsigned long long count=0,value=0,h_power=0,index=0;
while(X!=0)
{
	if(X%10 == 1)
	{
		index=pow(2,count);
		value=index+value;
			
			if((value%index)==0)
			{
				h_power=count;				
			}
	}

X=X/10;
count++;
}
cout<<h_power<<endl;

return 0;
}

Thanks

#include<iostream>
#include<cmath>
#include <vector>

using namespace std;


int main(){
unsigned long long int N;
cin>>N;
unsigned long long int value=0,h_power=0,index=1,power;

string X;
cin>>X;

while(index<=N)
{
	 power=pow(2,index-1);
	   value=((X[N-index]%48)*pow(2,index-1))+value;
		if(value%power == 0)
			h_power=index-1;

index++;
}
//cout<<value<<endl;
cout<<h_power<<endl;

return 0;
}

In this code iam getting sigfpe error.can you help me why its happening.