n = 5678

while n:

m = n % 10

n = n // 10

print(m)