Skip to content

Instantly share code, notes, and snippets.

@lethe2211
Created December 9, 2014 10:35
Show Gist options
  • Save lethe2211/9a3f2853d59acd4f0df3 to your computer and use it in GitHub Desktop.
Save lethe2211/9a3f2853d59acd4f0df3 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
class Hoge(object):
def __init__(self):
pass
def func(self):
'''
insert your code
'''
n, m = map(int, raw_input().split())
info = []
high = []
for i in range(m):
a, b = map(int, raw_input().split())
info.append((a, b))
if b == 1:
high.append(a)
while True:
flg = False
for a, b in info:
# print a, b
# print high
if b in high and not a in high:
high.append(a)
# print a
flg = True
if flg == True:
continue
else:
break
# print high
print len(high) + 1
return None
if __name__ == '__main__':
h = Hoge()
h.func()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment