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 <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[25][15][265];
 
signed main() {
    int N, K, S;
    while(cin >> N >> K >> S, N) {
        memset(dp, 0, sizeof(dp));
        dp[0][0][0] = 1;
        for(int i=1; i<=N; i++) {
            for(int k=0; k<=min(i, K); k++) {
                for(int s=0; s<=S; s++) {
                    // use
                    if(s+i <= S && k+1 <= K) dp[i][k+1][s+i] += dp[i-1][k][s];

                    // do not use
                    dp[i][k][s] += dp[i-1][k][s];
                }
            }
        }
        cout << dp[N][K][S] << endl;
    }
    return 0;
}

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

int rec(int n, int k, int s)
{
  if(s < 0) return 0;  // no answer
  if(k == 0) return s == 0 ? 1 : 0; // 0 by 0?
  if(n > k) {
    // using n, or not using n
    return rec(n-1, k-1, s-n) + rec(n-1, k, s);
  } else if(n == k) {
    if( s == n * (n+1) / 2 ) return 1;
  }
  return 0;
}
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) {
      cnt = rec(n, k, s);
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <bitset>

using namespace std;

int main(){
  int ans[21][11][156] = {0};
  int n, k, s;
  
  for(int i=1; i<(1<<20); i++){
    bitset<20> foo(i);
    if(foo.count() <= 10){
      int sum = 0;
      for(int j=0; j<20; j++)
	if(foo[j]==1)
	  sum+=(j+1);
      if(sum <= 155){
	int j = 19;
	while(foo[j] != 1)
	  j--;
	while(j<20){
	  ans[j+1][foo.count()][sum]++;
	  j++;
	}
      }
    }
  }
  
  while(cin >> n >> k >> s && n)
    cout << ans[n][k][s] << endl;   
  
  return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct R{string word;
int nl;int ty;

};

int main(){

	int n,k,s;
	while(1){
		cin>>n>>k>>s;
		if(n==0&&k==0&&s==0)break;
		int d=0;
		for(int i1=1;i1<=n;i1++)
		{if(k==1){if(i1==s)d++;}
		else{
		for(int i2=i1+1;i2<=n;i2++)
		{if(k==2){if(i1+i2==s)d++;}
		else{
		for(int i3=i2+1;i3<=n;i3++)
		{if(k==3){if(i1+i2+i3==s)d++;}
		else{
		for(int i4=i3+1;i4<=n;i4++)
		{if(k==4){if(i1+i2+i3+i4==s)d++;}
		else{
		for(int i5=i4+1;i5<=n;i5++)
		{if(k==5){if(i1+i2+i3+i4+i5==s)d++;}
		else{
		for(int i6=i5+1;i6<=n;i6++)
		{if(k==6){if(i1+i2+i3+i4+i5+i6==s)d++;}
		else{
		for(int i7=i6+1;i7<=n;i7++)
		{if(k==7){if(i1+i2+i3+i4+i5+i6+i7==s)d++;}
		else{
		for(int i8=i7+1;i8<=n;i8++)
		{if(k==8){if(i1+i2+i3+i4+i5+i6+i7+i8==s)d++;}
		else{
		for(int i9=i8+1;i9<=n;i9++)
		{if(k==9){if(i1+i2+i3+i4+i5+i6+i7+i8+i9==s)d++;}
		else{
			for(int i10=i9+1;i10<=n;i10++)
		{if(k==10)if(i1+i2+i3+i4+i5+i6+i7+i8+i9+i10==s)d++;}
		}}}}}}}}}}}}}}}}}}
	
	cout<<d<<endl;
	
	}	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int N, K, S;

int dfs(int sum, int n, int start) {
    if (sum == S && n == K) return 1;
    if (sum > S) return 0;
    if (n > K) return 0;

    int cnt = 0;
    REP(i, start, N + 1) {
        cnt += dfs(sum + i, n + 1, i + 1);
    }
    
    return cnt;
}

int main(void) {
    while (cin >> N >> K >> S, N) {
        cout << dfs(0, 0, 1) << endl;
    }

	return 0;
}