#include <bits/stdc++.h>
using namespace std;
 
int getAns() {
    int notPrime[2005] = {0};
    notPrime[1] = 1;
    for(int i = 2; i <= 2000; i++) {
        if(notPrime[i] == 0) {
            for(int j = 2 * i; j <= 2000; j += i) {
                notPrime[j] = 1;
            }
        }
    }

    int cnt = 0;
    for(int i = 1; i <= 1000; i++) {
        for(int j = i + 1; j <= 1000; j++) {
            for(int k = j + 1; k <= 1000; k++) {
                if(!(notPrime[i + j] || notPrime[j + k] || notPrime[i + k])) cnt++;
            }
        }
    }
    return cnt;
}
 
int main() {
	cout << getAns();
	return 0;
}