#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
    string s;
    cin >> s;

    int ans = 1000;
    for(int i = 0; i+2 < s.length(); i++){
        int num = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        if(abs(753-num) < ans) ans = abs(753-num);
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 && i % 5) ans += i;
  }
  cout << ans << endl;
  return 0;
}