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>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n, k, s;
    while (cin >> n >> k >> s, n|k|s) {
        int cnt = 0;
        REP(i, 1<<n) {
            if (__builtin_popcount(i) == k) {
                int sum = 0;
                REP(j, n) {
                    if ((i >> j) & 1) {
                        sum += j+1;
                    }
                }
                if (sum == s) {
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 

int n, k, s;
ll ans;

void rec(int num, int cnt, int sum)
{
	if (sum > s || cnt > k || num < 0) return;
	if (cnt == k) {
		if (sum == s) ans++;
		return;
	}
	rec(num-1, cnt+1, sum+num);
	rec(num-1, cnt, sum);
}

int main()
{
	while (1) {
		cin >> n >> k >> s;
		if (!n && !k && !s) break;

		int t = 0;
		rep(i,0,k) t += n - i;
		if (s > t || k > n) {
			//printf("t=%d k=%d n=%d\n",t,k,n);
			cout << 0 << endl;
			continue;
		}

		ans = 0;
		rec(n,0,0);
		cout << ans << endl;
	}

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n, k, s; cin >> n >> k >> s;
		if (n == 0) break;
		int cnt = 0;
		int comb = (1 << k) - 1;
		while (comb < (1 << n)) {
			int sum = 0;
			for (int i = 0; i < n; i++)
				if (comb & (1 << i)) sum += i + 1;
			if (sum == s) cnt++;
			int x = comb & -comb, y = comb + x;
			comb = (((comb & ~y) / x) >> 1) | y;
		}
		cout << cnt << endl;
	}
}

C++: #include <iostream>

using namespace std;
#define N 33000

int ans;

void solve(int n,int k,int s,int before,int cnt,int sum,int *data){	

	if(sum>s){
		return;
	}

	if(cnt==k){
		/*
		for(int i=0;i<cnt;i++){
			cout<<data[i]<<" ";
		}
		cout<<endl;
		*/
		if(sum==s){
			ans++;
		}
		return;
	}
	for(int i=before+1;i<=n;i++){
		data[cnt] = i;
		solve(n,k,s,i,cnt+1,sum+i,data);
	}
}

int main(){

	int n,k,s;
	int *data;
	data = new int[30];

	while(cin>>n>>k>>s){
		if(n==0 && k==0 && s==0)break;
	
		ans=0;

		solve(n,k,s,0,0,0,data);

		cout<<ans<<endl;
	}

	return 0;
}