import std.stdio, std.algorithm, core.bitop;

void main(){
	int A, B, K, ans;
	scanf("%d%d%d", &A, &B, &K);
	foreach(bit; 0..1<<10)if(popcnt(bit) <= K){
		ans = max(ans, test(A, B, bit));
	}
	writeln(ans);
}

int test(int A, int B, int bit){
	int carry = 0, ten = 1, C = 0;
	for(;A;A/=10, B/=10, ten*=10, bit>>=1){
		int x = A%10, y = B%10;
		if(x - carry >= y){
			C += ten * (x - carry - y);
			carry = 0;
		}
		else{
			C += ten * (x - carry + 10 - y);
			carry = (bit&1) ? 0 : 1;
		}
	}
	return C;
}