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;

int a,b,c;
int np;
int ans=0;

int dfs(int x,int d){
	d++;
	if(d==b){
		if(np==c)ans++;
		return 0;
	}
	if(d<b){
		for(int i=x+1;i<=a;i++){
			np+=i;
			dfs(i,d);
			np-=i;
		}
	}
	return 0;
}

int main(){
	while(cin>>a>>b>>c){
		ans=0;
		if(a==0&&b==0&&c==0)break;
		for(int i=1;i<=a;i++){
			np=i;
			dfs(i,0);
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[22][22][200];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,s;
  while(cin>>n>>k>>s,n+k+s){
    for(int i=0;i<22;i++)
      for(int j=0;j<22;j++)
	for(int k=0;k<200;k++)
	  dp[i][j][k] = 0;
    dp[0][0][0] = 1;

    for(int i=0;i<n;i++){
      for(int j=0;j<20;j++){
	for(int k=0;k<160;k++){
	  if(dp[i][j][k]){
	    dp[i+1][j+1][k+(i+1)] += dp[i][j][k];
	  }
	  dp[i+1][j][k]+=dp[i][j][k];
	}
      }
    }
    cout<<dp[n][k][s]<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    while (true) {
        int n, k, s; scanf("%d%d%d", &n, &k, &s);
        if (n == 0 and k == 0 and s == 0) break;
        int result = 0;
        repeat (x, 1 << n) if (__builtin_popcount(x) == k) {
            int acc = 0;
            repeat (i, n) if (x & (1 << i)) {
                acc += i + 1;
            }
            result += (acc == s);
        }
        printf("%d\n", result);
    }
    return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int n, k, s;
int calc(int x, int cnt, int sum) {
  if(cnt == k) {
    return sum == s;
  }
  if(sum > s) return 0;
  int ret = 0;
  FOR(i,x+1,n+1) {
    ret += calc(i, cnt + 1, sum + i);
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>n>>k>>s,n||k||s) {
    cout << calc(0, 0, 0) << endl;
  }
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void DEBUG(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
void ADD(T &a, const T &b) {
    T val = ((a % MOD) + (b % MOD)) % MOD;
    a = val;
}

int n, k, s;

long long solve(int sum, int depth, int cnt) {
    long long ans = 0;

    if (cnt == k) {
        ans = (sum == s ? 1 : 0);
    } else if (depth < n) {
        ans = solve(sum + depth + 1, depth + 1, cnt + 1) + solve(sum, depth + 1, cnt);
    }

    return ans;
}

int main() {
    while (cin >> n >> k >> s && n) {
        cout << solve(0, 0, 0) << endl;
    }

    return 0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int dfs(int i, int count, int sum, int n, int k, int s) {
     if (count == k) {
         if (sum == s) return 1;
         else return 0;
     } else if (count > k) {
        return 0;
     } else {
         int ans = 0;
         for (int j = i+1; j <= n; j++) {
             ans += dfs(j, count+1, j+sum, n, k, s);
         }
         return ans;
     }
}

int main()
{
    int n,k,s;
    while (cin >> n >> k >> s, n) {
        cout << dfs(0,0,0,n,k,s) << endl;
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXIST2(s,e) (find(ALL(s),(e))!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

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