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

int main() {
  while(true){
    int a,b,ans = 0;
    cin >> a >> b;
    if(a == 0 && b == 0) return 0;
    for(int i = 1;i < a;i++){
      for(int j = i+1;j <= a;j++){
        if(b-i-j <= a && b-i-j > j) ans++;
      }
    }
    cout << ans << endl;
  }
}

