#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int> ,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
void convert(int x,int base)
{
    if(x == 0)
        return;
    convert(x / base,base);
    cout << x%base;
    return;
}
struct hashFunc
{
    string s;
    vector<long long> prefixHash;
    vector<long long> suffixHash;
    long long MOD;
    long long p;
    vector<long long> hashPower;

};
void setPrefixHash(hashFunc& hashStruct)
{
    hashStruct.prefixHash.resize(hashStruct.s.length());
    long long curSum = 0;
    for(int i = 0;i < hashStruct.s.length();i++)
        curSum = ((curSum * hashStruct.p) % hashStruct.MOD + (hashStruct.s[i])) % hashStruct.MOD,hashStruct.prefixHash[i] = curSum;
}
void setSuffixHash(hashFunc& hashStruct)
{
    hashStruct.suffixHash.resize(hashStruct.s.length());
    long long curSum = 0;
    for(int i = hashStruct.s.length()-1;i >= 0;i--)
        curSum = ((curSum * hashStruct.p) + (hashStruct.s[i])) % hashStruct.MOD,hashStruct.suffixHash[hashStruct.s.length() - i - 1] = curSum;
}
long long getHash(int l,int r,hashFunc& hashStruct,bool isSuffix)
{
    if(!isSuffix)
    {
        long long enddy = hashStruct.prefixHash[r] % hashStruct.MOD;
        long long starto = (l ? hashStruct.prefixHash[l-1] : 0);
        starto = (starto * hashStruct.hashPower[r-l+1]) % hashStruct.MOD;
        return (((enddy - starto) % hashStruct.MOD) + hashStruct.MOD) % hashStruct.MOD;
    } else
    {
        r = hashStruct.s.length() - r - 1;
        l = hashStruct.s.length() - l - 1;
        if(l > r)
            swap(l,r);
        long long enddy = hashStruct.suffixHash[r];
        long long starto = (l ? hashStruct.suffixHash[l-1] : 0);
        starto = (starto * hashStruct.hashPower[r-l+1]) % hashStruct.MOD;
        return (((enddy - starto) % hashStruct.MOD) + hashStruct.MOD) % hashStruct.MOD;
    }
}
void readyHashPower(long long m,long long pp,hashFunc& hashStruct)
{
    hashStruct.MOD = m;
    hashStruct.p = pp;
    hashStruct.hashPower.resize(hashStruct.s.length()+1);
    hashStruct.hashPower[0] = 1;
    for(int i = 1;i < hashStruct.hashPower.size();i++)
        hashStruct.hashPower[i] = (hashStruct.hashPower[i-1] * hashStruct.p) % hashStruct.MOD;
}
//dp[i][j][k] = dp[i-1][j-1][s-i] + dp[i-1][j][s];
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int best = 1e5;
    string s;
    cin >> s;
    for(int i = 0;i < s.length()-2;i++)
    {
        int f = (s[i] - '0') * 100;
        f += (s[i+1] - '0') * 10;
        f += (s[i+2] - '0');
        best = min(best,abs(f-753));
    }
    cout << best;
    return 0;
}


Measured memory_bytes: 256