Main=(e=>{e=+e;let t=0,l=e=>{let t=e.sort((e,t)=>e-t);return r(r(t[0],t[1]),t[2])},r=(e,t)=>{let l=e%t;return 0===l?t:r(t,l)};for(let r=1;r<=e;r++)for(let o=r;o<=e;o++)for(let n=o;n<=e;n++){let e=[r,o,n],f=e.filter((e,t,l)=>l.indexOf(e)===t).length;f=1===f?1:2===f?3:6,t+=l(e)*f}console.log(t)}); Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());