Code:
#include <bits/stdc++.h> #define N 3000000 using namespace std; char str[N]; int main() { int minv=10,cur,len; scanf("%s",str+1),len=strlen(str+1); for(int i=1;i<=len;++i) { minv=min(minv, str[i]-'0'); cur=str[i]-'0'; } printf("%d ",(minv-cur+10)%10); return 0; }