#include<iostream>
#include<algorithm>
using namespace std;
int main () {
int l;
int j;
int a=l;
int b=j;
int N;
int x;
int y;
int c;
int d;
int z=j*l;
cin>>a;
cin>>b;
cin>>N;
cin>>c;
cin>>d;
if (a>0 || b>0 || c>0 || d>0){
    cout<<1000*(a-1)+100*(b-1)+10*(c-1)+d-1;
}
return 0;
}
