#include <bits/stdc++.h>
using namespace std;

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

    int d = INT_MAX;
    for (int i = 0, n = s.length() - 3; i <= n; i++) 
        d = min(d, abs(atoi(s.substr(i, 3).c_str()) - 753));

    cout << d << endl;
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){

    int n; cin >> n;
    int cnt = 0;
    for(int i = 2; i <= 55555; i++){
        if(divisor(i).size() == 2 && i%5 == 1){
            cout << i;
            cnt++;
            if(cnt == n) break;
            cout << " ";
        } 
    }
    cout << endl;
    return 0;   
}
