#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min({a, b, c, d}) << endl;

    return 0;
}
#include<bits/stdc++.h>
#define ll long long int
#define vt vector
#define f(i,n) for((i)=0;(i)<(n);(i)++)
#define fd(i,n) for((i)=n-1;(i)>=0;(i)--)
#define pb push_back
using namespace std;
int main(){
    ll t=1;
//cin>>t;
    while(t--){
        ll a,b,c,x,y,z;
        cin>>a>>b>>c;
        if (a==1)
            x=6;
        else if(a==2)
            x=5;
        else if(a==3)
            x=4;
        else if(a==4)
            x=3;
        else if(a==5)
            x=2;
        else
            x=1;
        if (b==1)
            y=6;
        else if(b==2)
            y=5;
        else if(b==3)
            y=4;
        else if(b==4)
            y=3;
        else if(b==5)
            y=2;
        else
            y=1;
        if (c==1)
            z=6;
        else if(c==2)
            z=5;
        else if(c==3)
            z=4;
        else if(c==4)
            z=3;
        else if(c==5)
            z=2;
        else
            z=1;
        cout<<x+y+z<<endl;
    }
    return 0;
}