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 <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


int count(int k, int s, set<int>& ok, set<int> &ng){
    int res=0;

    int ngmax=*max_element(ng.begin(),ng.end());
    
    ok.erase(ok.begin(),lower_bound(ok.begin(),ok.end(),ngmax));

    set<int> oktmp=ok;

    for(auto it=ok.begin();it!=ok.end();it++){
        int nextint=*it;
        if(s<nextint)break;
        oktmp.erase(oktmp.find(nextint));
        ng.insert(nextint);
        
        if(k==1&&s==nextint)res++;
        else res+=count(k-1,s-nextint,oktmp,ng);

        ng.erase(ng.find(nextint));
        oktmp.insert(nextint);
    }
    
    return res;
}

int main(void){

    while(1){
        int n,k,s;
        cin>>n>>k>>s;
        if(n==0)break;
        set<int> ok,ng;
        rep(i,n)ok.insert(i+1);
        cout<<count(k,s,ok,ng)<<endl;

    }

}

C++: #include <iostream>
using namespace std;

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

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

C++: #include <iostream>
using namespace std;
int main() {
  int n, k, s, ans, t, u;
  while (cin >> n >> k >> s, n) {
    int A[k];
    for (int i = 0; i < k-1; ++i) A[i] = i+1;
    A[k-1] = s - k*(k-1)/2;
    ans = 0;
    t = k-2;
    while (A[k-1] > A[k-2]) {
      if (A[k-1] <= n) ++ans;
      ++A[t];
      --A[t+1];
      if (A[t] >= A[t+1]) {
	while (t > 0) {
	  --t;
	  ++A[t];
	  u = 0;
	  for (int i = 0; i <= t; ++i) u += A[i];
	  for (int i = t+1; i < k-1; ++i) {
	    A[i] = A[i-1]+1;
	    u += A[i];
	  }
	  A[k-1] = s - u;
	  if (A[k-1] > A[k-2]) {
	    t = k-2;
	    break;
	  }
	}
	if (!t) break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int ans;
int n,k,s;
vector<int> debug;
void checker(int st,int dep,int cnt);
int main() {
  while(true){
    cin >> n >> k >> s;
    if(n==0&&k==0&&s==0) break;
    ans=0;
    checker(0,1,0);
    cout << ans << endl;
  }
  return 0;
}

void checker(int st,int dep,int cnt){
  if(dep<k) REP(i,st,n){
      debug.push_back(i+1);
      checker(i+1,dep+1,cnt+i+1);
      debug.pop_back();
    }else REP(i,st,n) if(cnt+i+1==s){
      ans++;
      //      rep(j,k-1) cout << debug[j] << ",";
      //      cout << i+1 << endl;
    }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int dp[15][25][200];

signed main(){
    while(1){
        int n, K, s;
        cin >> n >> K >> s;
        if(n + K + s == 0) break;
        rep(i, 0, 15) rep(j, 0, 25) rep(k, 0, 200) dp[i][j][k] = 0;
        dp[0][0][0] = 1;
        rep(i, 0, K){
            rep(j, 0, n){//pre
                rep(k, j + 1, n + 1){//new
                    rep(l, 0, s + 1){
                        // dp[i + 1][j][l] += dp[i][j][l];
                        // if(dp[i][j][l] == -1) continue;
                        if(l + k > s) continue;
                        // if(dp[i + 1][k][l + k] == -1) dp[i + 1][k][l + k] = 0;
                        dp[i + 1][k][l + k] += dp[i][j][l];
                    }
                }
            }
        }
        int ans = 0;
        // rep(i, 0, K + 1){
        //     rep(j, 0, n){
        //         rep(k, 0, 30){
        //             cout << dp[i][j][k] << " ";
        //         }
        //         cout << endl;
        //     }
        //     cout << endl << endl;
        // }
        rep(i, 0, n + 1){
            ans += dp[K][i][s];
        }
        cout << ans << endl;
    }
}