using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner input;
    static void Main()
    {
        input = new Scanner();
        string s = input.String();
        int min = 1000000000;
        for(int a = 0; a < s.Length-2; a++)
        {
            int temp = int.Parse(s.Substring(a,3));
            min=Math.Min(min,Math.Abs(753-temp));
        }
        WriteLine(min);

    }
    static double f(double a)
    {
        if (a%2 == 0)
        {
            return (double)(a/2);
        }
        else
        {
            return (double)(3*a+1);
        }

    }
}

class Scanner
{

    public Scanner()
    {
    }

    public void skip()
    {
        ReadLine();
        return;
    }
    public string String()
    {
        return ReadLine();
    }
    public string[] splitString()
    {
        return ReadLine().Split();
    }
    public string[] linesString(int len)
    {
        var arr = new string[len];
        for(int a = 0; a < len; a++)
        {
            arr[a] = ReadLine();
        }
        return arr;
    }
    public string[][] jaggedArrayString(int len)
    {
        var arr = new string[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split();
        }
        return arr;
    }
    public int Int()
    {
        return int.Parse(ReadLine());
    }
    public int[] splitInt()
    {
        return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    }
    public int[] linesInt(int len)
    {
        var arr = new int[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = int.Parse(ReadLine());
        }
        return arr;
    }
    public int[][] jaggedArrayInt(int len)
    {
        var arr = new int[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        }
        return arr;
    }
    public long Long()
    {
        return long.Parse(ReadLine());
    }
    public long[] splitLong()
    {
        return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
    }
    public long[] linesLong(int len)
    {
        var arr = new long[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = long.Parse(ReadLine());
        }
        return arr;
    }
    public long[][] jaggedArrayLong(int len)
    {
        var arr = new long[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => long.Parse(i)).ToArray();
        }
        return arr;
    }
    public double Double()
    {
        return double.Parse(ReadLine());
    }
    public double[] splitDouble()
    {
        return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
    }
    public double[] linesDouble(int len)
    {
        var arr = new double[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = double.Parse(ReadLine());
        }
        return arr;
    }
    public double[][] jaggedArrayDouble(int len)
    {
        var arr = new double[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => double.Parse(i)).ToArray();
        }
        return arr;
    }
}

Measured memory_bytes: 11220