#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  string S;
  cin >> S;
  int ans = INF;
  rep(i, 0, S.size() - 2) {
    int x = stoi(S.substr(i, 3));
    ans = min(ans, abs(753 - x));
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9+7;
signed main() {
    int N;
    cin >> N;
    vector<int>cnt(N+1,1);
    for(int i = 2; i <= N; i++) {
        int X = i;
        for(int j = 2; j*j <= i; j++) {
            int Y = j;
            if(X%Y == 0) {
                while(X%Y == 0) {
                    cnt[Y]++;
                    X/=Y;
                }
            }
        }
        if(X != 1) {
            cnt[X]++;
        }
    }
    int ans = 1;
    for(int i = 2; i <= N; i++) {
        ans*=cnt[i];
        ans = ans%INF;
    }
    cout << ans << endl;
}