#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

int main(){
    
    ifstream infile ;
    infile.open("DATA3.txt", ios::in);
    
    ofstream outfile;
    outfile.open("OUT3.txt", ios::out);
    
    int sum=0, a[8],in[5], output[5], s=0, total =0,dig=0, g=0;
    float x;
    
    outfile << total <<"\n";
    
    for(int i=0; i<5; i++){        
        infile >> in[i];
    }
        
        
    for(int i=0; i<5; i++){  
          x=    in[i];
        for(int j=8; j>0; j++)
        {
           if (int(x / pow(10.0,j)) > 1)
           { 
               a[s]=int(x / pow(10.0,j));
               dig++;
           }
           else 
               a[s]=0;     
           
           if (int(x / pow(10.0,j)) == 1) 
               sum++;
           
           s++;
        }  
        
        sum=sum*(9-dig)*pow(2.0,int(9-dig));
        
        for(int i=1; i<=(9-dig); i++){
            g=g+(9-dig)*i;           
        }
        total=1024-sum-g;
        
        output[i]=total;
        
    }
    for(int i=0; i<5; i++){
    outfile << output[i] <<"\n";
    }
    
    infile.close ();
    outfile.close();
    

}

