Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		N, K, S := io.NextInt(), io.NextInt(), io.NextInt()
		if N == 0 {
			break
		}
		dp := [21][11][156]int{}
		for i := 0; i <= N; i++ {
			dp[i][0][0] = 1
		}
		for i := 1; i <= N; i++ {
			for j := 1; j <= K; j++ {
				for k := 1; k <= S; k++ {
					if k-i >= 0 {
						dp[i][j][k] += dp[i-1][j-1][k-i]
					}
					dp[i][j][k] += dp[i-1][j][k]
				}
			}
		}
		io.Println(dp[N][K][S])
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

int n,m,k;

int main(){
	while(1){
		cin>>n>>m>>k;
		if(n==0) break;
		vvi dp(m+1,vi(k+1));
		dp[0][0]++;
		for(int i=1;i<=n;i++){
			vvi DP=dp;
			for(int j=0;j<m;j++) for(int l=0;l<=k-i;l++) DP[j+1][l+i]+=dp[j][l];
			dp=DP;
		}
		cout<<dp[m][k]<<endl;
	}
}

C++: #include <stdio.h>
long long d[11][21][156];
int main() {
	d[0][0][0] = 1;
	for (int i = 1; i <= 10; i++) {
		for (int j = 0; j < 20; j++) {
			for (int k = j + 1; k <= 20; k++) {
				for (int s = 0; s <= 155 - k; s++)
					d[i][k][s + k] += d[i - 1][j][s];
			}
		}
	}
	int N, K, S;
	while (scanf("%d%d%d", &N, &K, &S), N) {
		long long res = 0;
		for (int i = 1; i <= N; i++) res += d[K][i][S];
		printf("%lld\n", res);
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){

  int N,K,S;
  while(cin >> N >> K >> S,N|K|S){

  int dp[11][21][200];
  fill(*dp[0],*dp[11],0);
  dp[0][0][0]=1;

  for(int l=0;l<K;l++){
    for(int i=0;i<N;i++){
      for(int j=0;j<200;j++){
	for(int k=i+1;k<=N;k++){
	  if(j+k<200) dp[l+1][k][j+k]+=dp[l][i][j];
	}
      }
    }
  }

  int ans=0;
  for(int i=0;i<=N;i++)ans+=dp[K][i][S];

  cout << ans << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main(){
  int n,k,s;
  while(cin >> n >> k >> s, n|k|s ){
    int dp[k+1][s+1];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    REP(value,1,n+1){
      for(int use=k-1;use>=0;use--){
	rep(cur,s+1){
	  int next = cur + value;
	  if( next <= s ) {
	    dp[use+1][next] += dp[use][cur];
	  }
	}
      }
    }
    cout << dp[k][s] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
const int N = 20;

// next_combination version
// given an integer cur, next_combination returns an integer nxt s.t.
//   nxt has the same number of 1s as cur
//   nxt is bigger than cur
//   no integer between cur and nxt has the same number of 1s as cur (and nxt)
int next_combination(int cur)
{
  int r1 = cur & -cur;   // extracts the rightmost 1
  int moved1 = cur + r1; // cancel the rightmost run of 1s and put 1 on its left
  int rm1s = cur & ~moved1; // extracts the rightmost run of 1s
  int reset = (rm1s / r1) >> 1; // the run of 1s moved to LSD and made its length decreased by 1
  int nxt = moved1 | reset; // new combination
  return nxt;
}
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    if(k <= n) {
      const int fin = ((1<<k) - 1) << (n-k);
      for(int i = (1<<k) - 1; ; i = next_combination(i)) {
        int ss = 0;
        for(int j = 1, x = 1; j <= i; j<<=1, x++) {
          if(i & j) { ss+=x; }
        }
        if(s == ss) cnt++;
        if(i == fin) break;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    for(int i = 0; i < 1<<n; i++) {
      int c = 0, ss = 0, ii = i;
	  while(ii != 0) {
		int x = ii & -ii;
		ii ^= x;
		ss += __builtin_ffs(x);
		c++;
	  }
      if(c == k && s == ss) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, k, s;
		cin >> n >> k >> s;
		if (!n)break;
		
		int ans = 0;
		REP(i, 1 << n) {
			int sum = 0;
			int cnt = 0;
			REP(j, n) {
				if (i & (1 << j)) {
					sum += j + 1;
					cnt++;
				}
			}
			if (sum == s&&cnt==k)ans++;
		}
		cout <<ans << endl;
	}
	return 0;
}