#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  string a,b;
  int k;
  cin >> a >> b >> k;
  int n = a.size();
  while(b.size() < n)b="0"+b;

  int result = 0;
  REP(mask,1<<n){
    if(__builtin_popcount(mask)>k)continue;
    int bor = 0;
    int ret = 0;
    int base = 1;
    REP(i,n){
      int ca = a[n-1-i]-'0';
      int cb = b[n-1-i]-'0';
      if(ca-bor >= cb){
        ret += (ca-bor-cb)*base;
        bor = 0;
      }else{
        ret += (ca-bor+10-cb)*base;
        bor = 1;
        if(mask & (1<<i)) bor = 0;
      }
      base *= 10;
    }
    result = max(result,ret);
  }

  cout << result << endl;

  return 0;
}