#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	T f = 1; x = 0;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
	x *= f;
}
template <typename T>
void write(T x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) write(x / 10);
	putchar(char(x % 10 + 48));
}
template <typename T>
void writeln(T x, char ch = '\n')
{
	write(x);
	putchar(ch);
}
int n, m, k;
int main()
{
	read(n); read(m); read(k);
	cout << (n - m + k) << endl;
	return 0;
}

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

int main(){
  int N,K,A;
  cin >> N >> K;
  string S;
  
  for(int i=0;i<K;i++){
    S=to_string(N);
    sort(S.begin(), S.end());
    
    A=stoi(S);
    
    reverse(S.begin(), S.end());
    
    N=stoi(S)-A;
  }
  cout << N << endl;
}