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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int n, k, s, ans;
void solve(int deep = 0, int sum = 0, int back = 0) {
	if (deep == k) {
		if (sum == s)ans++;
		return;
	}
	for (int i = back + 1; i <= n; i++) {
		solve(deep + 1, sum + i, i);
	}
	return;
}
signed main() {
	while (cin >> n >> k >> s, n || k || s) {
		ans = 0;
		solve();
		cout << ans << endl;
	}
	return 0;
}

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

int main(void){
    int n, k, s;
    while(cin>>n>>k>>s, n){
        ll ans=0;
        for(int i=0; i<(1<<n); i++){
            int sum=0, count=0;
            for(int j=0; j<n; j++){
                if((1&i>>j)==1) {
                    sum+=j+1;
                    count++;
                }
            }
            if(count==k&&sum==s) ans++;
        }
        cout << ans << "\n";
    }

}

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

int solve(int n, int k, int s) {
    if(k == 0 && s == 0) return 1;
    int res = 0;
    for(int i = 1; i <= n; i++) {
        res += solve(i - 1, k - 1, s - i);
    }
    return res;
}

int main() {
    while(true) {
        int N, K, S; cin >> N >> K >> S;
        if(N == 0 && K == 0 && S == 0) break;
        cout << solve(N, K, S) << endl;
    }
}

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

using namespace std;

int main()
{
    while (true) {
        int n, k, s;
        cin >> n >> k >> s;
        if (n == 0 && k == 0 && s == 0) {
            break;
        }

        int count = 0;
        // k個選ぶ
        std::string bitMask(k, 1);
        // n個の中から
        bitMask.resize(n, 0);
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                // 組み合わせに選ばれた値
                if (bitMask[i]) {
                    // 0からなので1ずらす
                    sum += i + 1;
                }
            }
            if (sum == s) {
                count += 1;
            }
            // 次のマスクを求める
        } while (std::prev_permutation(bitMask.begin(), bitMask.end()));
        cout << count << endl;
    }
}

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

int dfs(int n,int k,int s,int i,int pre,int sum){
    if(i==k){
        if(sum==s)
            return 1;
        else
            return 0;

    }
    int cnt=0;
    for(int j=pre+1;j+sum<=s && j<=n;j++){
        if((k-i)*j+(k-i)*(k-i-1)/2+sum<=s){
            cnt+=dfs(n,k,s,i+1,j,sum+j);
            }


    }
    return cnt;


}

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



    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int n,k,s;
ll ans;

void rec(int div,int used,int sum){
	if(sum==s&&div==k){
		ans++;
		return;
	}
	if(sum>s||div==k)return;
	range(i,used+1,n-k+div+1+1){
		rec(div+1,i,sum+i);
	}
}

void solve(){
	ans=0;
	rec(0,0,0);
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin>>n>>k>>s,n)solve();
}

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

unsigned foo(unsigned n, unsigned k, unsigned s, unsigned temp,int m){
	unsigned ans = 0;//cout<<n<<" "<<k<<" "<<s<<" "<<temp<<" "<<m<<endl;
	if(k==0){
		if(temp == s) return 1;
		else return 0;
	}
	for(int i = m; i <= n; i++){
		ans += foo(n,k-1,s,temp+i,i+1);
	}
	return ans;
}

int main(){
	unsigned n, k, s;
	
	while(1){
		cin>>n>>k>>s;
		if(!n&&!k&&!s)break;
		cout<<foo(n,k,s,0,1)<<endl;
	}
	return 0;
}