#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    char c[3]={};
    int k,ans=999;
    cin>>s;
    for(int i=0;i<s.size()-2;i++)
    {
        c[0]=s[i];
        c[1]=s[i+1];
        c[2]=s[i+2];
        k=atoi(c);
       // cout<<"k = "<<k<<'\n';
        ans=min(abs(k-753),ans);
    }
    cout<<ans;
    return 0;
}



#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void)
{
    vector<ll> cost(5);
    ll N;
    cin >> N;
    for (int i = 0; i < 5; i++)
    {
        cin >> cost[i];
    }
    

    ll result = (ll) ceil((double) N / *min_element(cost.begin(), cost.end())) + 4;
    cout << result << endl;

    return 0;
}
