/*
   Snippets :-
   1. Binomial (nCr) - nCr Modulo
   2. (x^y)mod m - power
   3. gcd & lcm - gcd
   4. Djisktra - Djikstra
   5. Priority Queue - priority
   6. Disjoint Set Union - dsu
   7. Compare Sort [sort pair with customisation] - compare
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define mod 1000000007
# define con continue
# define ret return
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
/*
   #include <ext/pb_ds/assoc_container.hpp> 
   #include <ext/pb_ds/tree_policy.hpp> 
   using namespace __gnu_pbds;   
   #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
   // find_by_order() - Returns an iterator to the k-th largest element (counting from zero)
   // order_of_key()  - The number of items in a set that are strictly smaller than our item
*/
void func()
{
   #ifndef ONLINE_JUDGE
   freopen("in.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
   #endif
   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int32_t  main()
{
   ll t;
    t=1;
   // cin>>t;  
   while(t--)
   {
     ll n,k;
     cin>>n>>k;
     ll sum=0;
     for(ll i=1;i<=n;i++)
     {
      for(ll j=1;j<=k;j++)
      {
        sum+=(i*100+j);
      }
     }
     cout<<sum;
   }
}



#include<bits/stdc++.h>
#include <sstream>  // for string streams 
using namespace std;

int main()
{
	long long N,K;
	cin>>N>>K;
	
	for(int b=0;b<K;b++)
	{
		
	ostringstream str1;
	
	str1<<N;
	
	string converted=str1.str();
	
	int len_num=converted.size();
	
	int a[len_num];
	int i=0;
	
	while(N!=0)
	{
		
			a[i]=N%10;
			N=N/10;
			i++;
	}
	
	sort(a,a+i);
	
	long long g_2=0;  //g2
	long long g_1=0;   //g1
	
	for(int j=0;j<i;j++)
	{
		if(a[j]!=0)
		g_1=g_1*10+a[j];
		
		g_2=g_2*10+a[i-1-j];
	}
	long long f_x=g_2-g_1;
	
	N=f_x;
	
	}
	
	cout<<N<<endl;
	
	
}