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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,1,4,4,9,11,14,16,25,20,32,29,38,38,56,45,70,61,74,69,92,71,103,88,105,100,136,98,131,113,131,119,150,118,150,119,160,119,150,118,150,119,131,113,131,98,136,100,105,88,103,71,92,69,74,61,70,45,56,38,38,29,32,20,25,16,14,11,9,4,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,5,7,13,22,25,32,49,52,62,76,88,91,119,114,146,160,170,172,231,223,249,269,298,297,372,326,375,404,407,424,484,464,481,514,553,533,581,554,589,653,597,601,657,630,647,660,643,643,660,647,630,657,601,597,653,589,554,581,533,553,514,481,464,484,424,407,404,375,326,372,297,298,269,249,223,231,172,170,160,146,114,119,91,88,76,62,52,49,32,25,22,13,7,5,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,11,19,38,44,62,88,106,124,170,188,221,271,276,323,397,395,438,533,544,568,687,694,769,861,893,942,1114,1078,1180,1293,1342,1351,1574,1491,1640,1748,1775,1764,2029,1920,2026,2162,2178,2191,2430,2292,2383,2552,2488,2488,2709,2583,2598,2777,2618,2659,2841,2657,2657,2841,2659,2618,2777,2598,2583,2709,2488,2488,2552,2383,2292,2430,2191,2178,2162,2026,1920,2029,1764,1775,1748,1640,1491,1574,1351,1342,1293,1180,1078,1114,942,893,861,769,694,687,568,544,533,438,395,397,323,276,271,221,188,170,124,106,88,62,44,38,19,11,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,7,16,28,59,75,109,151,206,234,335,360,467,529,630,675,896,878,1053,1141,1340,1294,1632,1571,1895,1896,2184,2129,2632,2485,2926,2909,3356,3190,3911,3583,4259,4158,4663,4477,5370,4886,5622,5475,6171,5776,6772,6186,7073,6776,7435,6953,8178,7344,8270,7927,8551,8030,9184,8285,9227,8758,9408,8650,9937,8868,9716,9281,9870,9035,10092,9035,9870,9281,9716,8868,9937,8650,9408,8758,9227,8285,9184,8030,8551,7927,8270,7344,8178,6953,7435,6776,7073,6186,6772,5776,6171,5475,5622,4886,5370,4477,4663,4158,4259,3583,3911,3190,3356,2909,2926,2485,2632,2129,2184,1896,1895,1571,1632,1294,1340,1141,1053,878,896,675,630,529,467,360,335,234,206,151,109,75,59,28,16,7,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,8,22,40,83,122,173,248,350,408,575,669,842,963,1211,1264,1652,1767,2083,2248,2752,2671,3274,3352,3928,3978,4624,4554,5428,5384,6115,6158,7195,6897,8052,7886,8928,8772,10083,9670,11309,10830,12110,11865,13681,12871,14740,14098,15900,15138,17241,15947,18464,17353,19307,18345,20745,18949,21681,20236,22624,21027,23607,21467,24536,22553,24793,23187,26012,23373,26355,24094,26581,24463,27187,24377,27453,24768,27006,24768,27453,24377,27187,24463,26581,24094,26355,23373,26012,23187,24793,22553,24536,21467,23607,21027,22624,20236,21681,18949,20745,18345,19307,17353,18464,15947,17241,15138,15900,14098,14740,12871,13681,11865,12110,10830,11309,9670,10083,8772,8928,7886,8052,6897,7195,6158,6115,5384,5428,4554,4624,3978,3928,3352,3274,2671,2752,2248,2083,1767,1652,1264,1211,963,842,669,575,408,350,248,173,122,83,40,22,8,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,9,28,51,107,177,234,360,498,619,819,1040,1252,1528,1824,2010,2533,2837,3180,3676,4305,4493,5130,5672,6156,6909,7424,7830,8773,9392,9892,10678,11647,12141,13026,13918,14519,15611,16278,16780,18686,19280,19586,20795,22385,22896,23948,24970,26012,27096,28467,28427,30540,31272,31774,33264,34748,34499,36299,36596,38456,38926,39984,39386,42068,42848,42424,42925,45044,44584,46040,45496,46890,47036,47341,47646,48887,48840,48044,48540,50066,48970,49062,49062,48970,50066,48540,48044,48840,48887,47646,47341,47036,46890,45496,46040,44584,45044,42925,42424,42848,42068,39386,39984,38926,38456,36596,36299,34499,34748,33264,31774,31272,30540,28427,28467,27096,26012,24970,23948,22896,22385,20795,19586,19280,18686,16780,16278,15611,14519,13918,13026,12141,11647,10678,9892,9392,8773,7830,7424,6909,6156,5672,5130,4493,4305,3676,3180,2837,2533,2010,1824,1528,1252,1040,819,619,498,360,234,177,107,51,28,9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,9,28,51,107,177,234,360,498,619,819,1040,1252,1528,1824,2010,2533,2837,3180,3676,4305,4493,5130,5672,6156,6909,7424,7830,8773,9392,9892,10678,11647,12141,13026,13918,14519,15611,16278,16780,18686,19280,19586,20795,22385,22896,23948,24970,26012,27096,28467,28427,30540,31272,31774,33264,34748,34499,36299,36596,38456,38926,39984,39386,42068,42848,42424,42925,45044,44584,46040,45496,46890,47036,47341,47646,48887,48840,48044,48540,50066,48970,49062,49062,48970,50066,48540,48044,48840,48887,47646,47341,47036,46890,45496,46040,44584,45044,42925,42424,42848,42068,39386,39984,38926,38456,36596,36299,34499,34748,33264,31774,31272,30540,28427,28467,27096,26012,24970,23948,22896,22385,20795,19586,19280,18686,16780,16278,15611,14519,13918,13026,12141,11647,10678,9892,9392,8773,7830,7424,6909,6156,5672,5130,4493,4305,3676,3180,2837,2533,2010,1824,1528,1252,1040,819,619,498,360,234,177,107,51,28,9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
};
int main(){
    int a,b;
    while(~scanf("%d%d",&a,&b)){
        if(a<=0||a>10||b<0||b>=360)printf("0\n");
        else printf("%d\n",ans[a-1][b]);
    }
}

Measured memory_bytes: 1052