
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')


# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)



# slower version:

s = input()[::-1]

l = len(s)

c = [0] * 2019

c[0] = 1

ten = 1

mod = 0

ans = 0



for i in range(l):

    mod = (mod + int(s[i]) * ten) % 2019

    ten = ten * 10 % 2019

    c[mod] += 1



for i in c:

    ans += i * (i - 1) // 2



print(ans)

# optimized version of the same code:

s = input()[::-1]

c = [0] * 2019

c[0] = 1

mod = 0

ten = 1

ans = 0



for i in s:

    mod = (mod + int(i) * ten) % 2019

    ten = ten * 10 % 2019

    c[mod] += 1



for i in c:

    ans += i * (i - 1) // 2



print(ans)
s = input()[::-1]
l = len(s)
c = [0] * 2019
c[0] = 1
ten = 1
mod = 0
ans = 0
for i in range(l):
    mod = (mod + int(s[i]) * ten) % 2019
    ten = ten * 10 % 2019
    c[mod] += 1
for i in c:
    ans += i * (i - 1) // 2
print(ans)

s = input()[::-1]
c = [0] * 2019
c[0] = 1
mod = 0
ten = 1
ans = 0
for i in s:
    mod = (mod + int(i) * ten) % 2019
    ten = ten * 10 % 2019
    c[mod] += 1
for i in c:
    ans += i * (i - 1) // 2
print(ans)

-l = len(s) +mod = 0 -mod = 0 -for i in range(l): -    mod = (mod + int(s[i]) * ten) % 2019 +for i in s: +    mod = (mod + int(i) * ten) % 2019