public class Euler163 {
    static final double EPS = 1e-10;

    public static void main(String[] args) {
        int SIZE = 36;
        double h = Math.sqrt(3.0) / 2.0;
        double[] cx = { 0.5 }, cy = { h };
        double[] bcx = { 0.75 }, bcy = { h / 2 };
        double[] acx = { 0.25 }, acy = { h / 2 };

        double[][] lines = new double[9 * SIZE][3];
        int lc = 0;
        for (int i = 0; i < SIZE; i++) {
            double y = i * h;
            lines[lc++] = makeLine(0, y, 1, y);
        }
        for (int i = 0; i < SIZE; i++) {
            double x = i;
            lines[lc++] = makeLine(x, 0, 0.75 + x, h / 2);
            if (i > 0)
                lines[lc++] = makeLine(-x, 0, 0.75 - x, h / 2);
        }
        for (int i = 0; i < SIZE; i++) {
            double x = i;
            lines[lc++] = makeLine(x, 0, 0.5 + x, h);
        }
        for (int i = 0; i < SIZE; i++) {
            double x = i;
            lines[lc++] = makeLine(x + 1, 0, 0.5 + x, h);
        }
        for (int i = 0; i < 2 * SIZE - 1; i++) {
            double x = i;
            lines[lc++] = makeLine(x + 1, 0, 0.25 + x, h / 2);
        }
        for (int i = 1; i < 2 * SIZE; i++) {
            double x = i * 0.5;
            lines[lc++] = makeLine(x, 0, x, h);
        }
        int n = lc;
        double AX = 0, AY = 0, BX = SIZE, BY = 0, CX = 0.5 * SIZE, CY = h * SIZE;

        double[][] pts = new double[n * n][];
        boolean[][] valid = new boolean[n][n];
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                double det = lines[i][0] * lines[j][1] - lines[j][0] * lines[i][1];
                if (Math.abs(det) < EPS)
                    continue;
                double px = (lines[i][2] * lines[j][1] - lines[j][2] * lines[i][1]) / det;
                double py = (lines[i][0] * lines[j][2] - lines[j][0] * lines[i][2]) / det;
                if (ld(AX, AY, BX, BY, px, py) < -EPS || ld(BX, BY, CX, CY, px, py) < -EPS
                        || ld(CX, CY, AX, AY, px, py) < -EPS)
                    continue;
                pts[i * n + j] = new double[] { px, py };
                valid[i][j] = true;
            }
        long count = 0;
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                if (!valid[i][j])
                    continue;
                double[] ij = pts[i * n + j];
                for (int k = j + 1; k < n; k++) {
                    if (!valid[i][k] || !valid[j][k])
                        continue;
                    double[] ik = pts[i * n + k], jk = pts[j * n + k];
                    if (sp(ij, ik) || sp(ij, jk) || sp(ik, jk))
                        continue;
                    count++;
                }
            }
        System.out.println(count);
    }

    static double[] makeLine(double px, double py, double qx, double qy) {
        return new double[] { py - qy, qx - px, qx * py - px * qy };
    }

    static double ld(double px, double py, double qx, double qy, double rx, double ry) {
        return (qx - px) * (ry - py) - (qy - py) * (rx - px);
    }

    static boolean sp(double[] a, double[] b) {
        return Math.abs(a[0] - b[0]) < EPS && Math.abs(a[1] - b[1]) < EPS;
    }
}
