#include<string>
#include<iostream>
#include<fstream>
#include<cmath>
#include<sstream>

using namespace std;
int binary(int j);
int main()
{
	ifstream fin;
	ofstream fout;
	fin.open("DATA3.txt");
	fout.open("OUT3.txt");
	for (int h=1;h<=5;h++)
	{
	int count=0;
	string bin;
	fin >> bin;
	string bintest[256];
	for (int i=0;i<256;i++)
	{
		stringstream sss;
		sss << binary(i);
		bintest[i]=sss.str();
		string tempstring = "";
		if (bintest[i].size() < 8)
		{
			for (int j=0;j < (8 - bintest[i].size());j++)
			{
				tempstring += "0";
			}
			tempstring += bintest[i];
			bintest[i] = tempstring;
		}
	}
	for (unsigned int i=0; i < 256; i++)
	{
		if (bintest[i].find(bin) == -1)
			{
				for (unsigned int j=0; j < bintest[i].size(); j++)
				{
					int num;
					num=bintest[i][j];
					if (num==49)
					{
						count += 1;
					}

				}
			}
	}
	fout << count << endl;
	}


}
int binary(int j)
	{
		j+=1;
		int k=0;
		for (int m=8;m>=0;m--)
		{
			double s=m;
			if (j>(pow(2,s)))
			{
				j = (int) (j-(pow(2,s)));
				k += (int)(pow(10,s));
			}

		}
		return k;
	}
