# -*- coding: utf-8 -*-
import re, os, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
base=os.path.dirname(os.path.abspath(__file__))
html=open(os.path.join(base,'index_main.html'),encoding='utf-8').read()
p0=html.index("const PROGRAMS=["); p1=html.index("const CATD=["); seg=html[p0:p1]
starts=[m.start() for m in re.finditer(r'\{id:"',seg)]
m=d=0
for i,a in enumerate(starts):
    b=starts[i+1] if i+1<len(starts) else len(seg); blk=seg[a:b]
    if re.search(r'lvl:"d"',blk): d+=1
    elif re.search(r'lvl:"m"',blk): m+=1
print("master",m,"phd",d,"total",m+d)
