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 rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int solve(int dlim, int k, int rem, int n){
    if(k == 1){
        if(rem <= n && dlim < rem) return 1;
        else return 0;
    }
    int ret = 0;
    for(int i = dlim+1; i <= n; i++){
        ret += solve(i, k-1, rem-i, n);
    }
    return ret;
}

int main(void){
    int n, k, s;
    while(true){
        cin >> n >> k >> s;
        if(n == 0) break;
        cout << solve(0, k, s, n) << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<string.h>
int main()
{	
    int n,k,s;
	int dp[25][160][15];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for (int i=1;i<=20;i++)
	{
        for (int j=0;j<=155;j++)
		{
            for (int k=0;k<=10;k++)
			{
                dp[i][j][k]=dp[i-1][j][k];
                if(k>0&&j>=i)
				{
					dp[i][j][k]=dp[i][j][k]+dp[i-1][j-i][k-1];
				}
            }
		}
	}
    while (scanf("%d%d%d",&n,&k,&s)!=EOF&&n!=0&&k!=0&&s!=0)
	{
		printf("%d\n",dp[n][s][k]);
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int n, k, s;
  while (cin >> n >> k >> s &&n  + k + s  > 0){

    int count = 0;
    REP(mask, 1 << n){
      if (__builtin_popcount(mask) == k){
        int sum = 0;
        REP(k, n){
          if ((mask >> k) & 1) sum += k + 1;
        }
        if (sum == s) count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

int dfs(int maxim, int left, int sum){
  int res = 0;
  if(left == 0 and sum == 0) return 1;
  for(int i=1; i<maxim; i++){
    if(sum < i) break;
    res += dfs(i, left-1, sum-i);
  }
  return res;
}

int main(){
  int n, k, s;
  while(cin >> n >> k >> s and n + k + s){
    int maxim = n+1;
    cout << dfs(maxim, k, s) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, K, s;
    while(scanf("%d%d%d", &n, &K, &s) && n){
        int ans = 0;
        rep(S, 1<<n)if(__builtin_popcount(S) == K){
            int sum = 0;
            rep(i, n)if(S>>i & 1) sum += i+1;
            if(sum == s) ++ans;
        }
        printf("%d\n", ans);
    }
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll dp[25][15][200];

ll rec(ll n, ll k, ll s){
	if(n == 0) return (s == 0) && (k == 0);
	if(k == 0) return s == 0;
	if(dp[n][k][s] != -1) return dp[n][k][s];
	ll res = 0;
	for(ll i=n; i>=1; i--){
		if(i <= s) res += rec(i-1,k-1,s-i);
	}
	return dp[n][k][s] = res;
}

int main(){
	rep(i,21) rep(j,11) rep(k,156) dp[i][j][k] = -1;
	while(1){
		ll n,k,s; cin >> n >> k >> s;
		if(n+k+s == 0) break;
		cout << rec(n,k,s) << endl;
	}
}