#include <stdio.h>
int n, m, c, i, j, k, ans;
char s[15];
int main(){
	scanf("%s", s);
	m = ans = 753;
	for(i=0; s[i+2]; i++){
		sscanf(s+i, "%3d", &n);
		c = n>m ? n-m : m-n;
		if(c < ans) ans = c;
	}
	printf("%d\n", ans);
	return 0;
}