#include <iostream>
#include <cmath>
using namespace std;
int binary_to_decimal(string s) {
int dec = 0;
for (int i = s.length() - 1, j = 0; i >= 0; i--, j++) {
if (s[i] == '1') {
dec += pow(2, j);
}
}
return dec;
}
int main()
{
string s = "10101011";
cout << binary_to_decimal(s) << endl;
}
/*
run:
171
*/