#include<bits/stdc++.h>
using namespace std;
const int N=20;
int a[N],vis[N];
int n,r;
int ans;
void dfs(int u) {
if(u==r+1) {
for(int i=1; i<=r; i++) {
printf("%d",a[i]);
}
ans++;
puts("");
return;
}
for(int i=a[u-1]; i>=1; i--) {
if(vis[i]==0) {
vis[i]=1;
a[u]=i;
dfs(u+1);
vis[i]=0;
}
}
}
int main() {
freopen("b.in","r",stdin);
freopen("b.out","w",stdout);
scanf("%d %d",&n,&r);
a[0]=n;
dfs(1);
printf("total=%d",ans);
puts("");
return 0;
}