Discussion About Tavas and SaDDas

This is Discussion thread about Tavas and SaDDas

how to solve this problem
what we have to find

#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int digits=ceil(log10(n));
int pos=0;
int b=2;
for(int i=1;i<digits;i++){
pos=pos+b;
b=b*2;
}
int l=0,r=pow(2,digits);
while(n != 0){
int p=pow(10,(digits-1));
int temp=n/p;
n=n%p;
if(temp==4){
r=(l+r)/2;
}
else if(temp==7){
l=(l+r)/2;
}
digits–;
}
pos=pos+r;
cout<<pos<<endl;

}