#27919: 速度過不了


shenshenchang0713 (107-05張宸紳)


#include <bits/stdc++.h>

using namespace std;

bool cmp(string s){

for (int i = 0; i < s.length(); i++)

if (s[i] % 2 == 0) return false;

return true;

}

string to_str(int n){

stringstream ss;

ss << n;

string s;

ss >> s;

return s;

}

main(){

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int n, j, k;

while (cin >> n){

k = n;

while (true){

if (cmp(to_str(k))) break;

k--;

}

j = n;

while (true){

if (cmp(to_str(j))) break;

j++;

}

cout << min(j-n, n-k) << endl;