Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you." [Image] 

The problem is: 

You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

If we sort all lucky numbers in increasing order, what's the 1-based index of n? 

Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.


-----Input-----

The first and only line of input contains a lucky number n (1 ≤ n ≤ 10^9).


-----Output-----

Print the index of n among all lucky numbers.


-----Examples-----
Input
4

Output
1

Input
7

Output
2

Input
77

Output
6

Difficulty: interview

Starter code:

Solutions:
n = input()
x = len(n)
n = n.replace('4', '0')
n = n.replace('7', '1')
tmp = 2 * (2**(x-1) - 1)
print(tmp + int(n, 2) + 1)

n = (input())
s = []
for i in range(len(n) - 1, -1 , -1):
    if int(n[i]) == 4:
        s.append(1)
    else:
        s.append(2)
cnt = 0
for i in range(len(s)):
    cnt += (2**i)*s[i]
print(cnt)


def main():
    n = int(input())
    k = 0
    i = 1
    while n // 10:
    
        k += 1*i if n % 10 == 4 else 2*i
        
        n //= 10
        i *= 2
    k += 1*i if n % 10 == 4 else 2*i
    print(k)
def __starting_point():
    main()

__starting_point()

inp = input()
n = int(inp)

c = 0
k = 10

while k**c < n:
    c += 1

res = 0
res += 2**c - 2

p = 1
for i in range(len(inp) - 1, -1, -1):
    ch = inp[i]
    if ch == '7':
        res += p
    p *= 2

res += 1
        

print(res)


n = input()
binary = []
for i in n:
    if i == '4':
        binary.append(0)
    else:
        binary.append(1)
binary.reverse()
ans = 0
for i in range(len(binary)):
    ans +=  2 ** i * (binary[i] + 1)
print (ans)

def generate(num, pref):
    nonlocal res
    if num == 0:
        res += 1
        if pref == n:
            print(res)
            return
    else:
        generate(num - 1, pref + '4')
        generate(num - 1, pref + '7')

n = input()
num = len(n)
res = 0
for i in range(1, num):
    res += 2 ** i
generate(num, '')
print(res)

d = set()

def binary_search(a, x, lo=0, hi=None):
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        midval = a[mid]
        if midval < x:
            lo = mid+1
        elif midval > x: 
            hi = mid
        else:
            return mid
    return -1

for i in range(512):
	s = str(bin(i))
	s = s[2:]
	s1 = ''
	s2 = ''
	for c in s:
		if(c=='0'):
			s1 += '4'
			s2 += '7'
		else:
			s1 += '7'
			s2 += '4'
	d.add(int(s1))
	d.add(int(s2))
l = list(d)
l.sort()

n = int(input())
print(binary_search(l,n) + 1)

n = input()
s = ''
for i in n:
    if i == '7':
        s = s+'1'
    else:
        s = s+'0'
ans = 0
for i in range(len(n)-1):
    ans += 2**(i+1)
print(ans+int(s,2)+1)


s = input()

ans = 1

def f(k):
    if k == '4':
        return 0
    return 1

for i in range(len(s)):
    ans = (ans << 1) + f(s[i])

print(ans - 1)


n = input()
n = n.replace('7', '1')
n = n.replace('4', '0')
length = len(n)
answer = 0
for i in range(length):
    answer += 2 ** i
t = 1
for d in reversed(n):
    if d == '1':
        answer += t
    t *= 2
print(answer)

a = list(str(input()))
a = [int(x) for x in a]
n = len(a)

ans = 0
for i in range(n):
    digs = n - i
    ans += 2 ** (digs-1)
    if a[i] == 4:
        continue
    else:
        ans += 2 ** (digs - 1)

print(ans)












n = input()
ans = 0
for i in range(len(n)):
    ans *= 2
    ans += 1
    if n[i] == "7":
        ans += 1
print(ans)

n = input()
ans = 0
len_n = len(n)
if len_n == 1:
    if n == '4':
        ans = 1
    else:
        ans = 2
else:
    ans += sum([2 ** n for n in range(1, len_n)])
    for i in range(len_n):
        if n[i] == '7':
            ans += 2 ** (len_n-i-1)
    ans += 1
print(ans)


a = input()[::-1]
count = 0
for i in range(len(a)):
    if a[i] == '7':
        count += 2 ** i * 2
    else:
        count += 2 ** i
print(count)

s=input().strip()
ans = 0
st=1
for i in range(len(s)-1, -1, -1):
    if s[i]=='4':
        ans+=st
    elif s[i]=='7':
        ans+=st*2
    st*=2
print(ans)

d = {
4: 1,
7: 2,
44: 3,
47: 4,
74: 5,
77: 6,
444: 7,
447: 8,
474: 9,
477: 10,
744: 11,
747: 12,
774: 13,
777: 14,
4444: 15,
4447: 16,
4474: 17,
4477: 18,
4744: 19,
4747: 20,
4774: 21,
4777: 22,
7444: 23,
7447: 24,
7474: 25,
7477: 26,
7744: 27,
7747: 28,
7774: 29,
7777: 30,
44444: 31,
44447: 32,
44474: 33,
44477: 34,
44744: 35,
44747: 36,
44774: 37,
44777: 38,
47444: 39,
47447: 40,
47474: 41,
47477: 42,
47744: 43,
47747: 44,
47774: 45,
47777: 46,
74444: 47,
74447: 48,
74474: 49,
74477: 50,
74744: 51,
74747: 52,
74774: 53,
74777: 54,
77444: 55,
77447: 56,
77474: 57,
77477: 58,
77744: 59,
77747: 60,
77774: 61,
77777: 62,
444444: 63,
444447: 64,
444474: 65,
444477: 66,
444744: 67,
444747: 68,
444774: 69,
444777: 70,
447444: 71,
447447: 72,
447474: 73,
447477: 74,
447744: 75,
447747: 76,
447774: 77,
447777: 78,
474444: 79,
474447: 80,
474474: 81,
474477: 82,
474744: 83,
474747: 84,
474774: 85,
474777: 86,
477444: 87,
477447: 88,
477474: 89,
477477: 90,
477744: 91,
477747: 92,
477774: 93,
477777: 94,
744444: 95,
744447: 96,
744474: 97,
744477: 98,
744744: 99,
744747: 100,
744774: 101,
744777: 102,
747444: 103,
747447: 104,
747474: 105,
747477: 106,
747744: 107,
747747: 108,
747774: 109,
747777: 110,
774444: 111,
774447: 112,
774474: 113,
774477: 114,
774744: 115,
774747: 116,
774774: 117,
774777: 118,
777444: 119,
777447: 120,
777474: 121,
777477: 122,
777744: 123,
777747: 124,
777774: 125,
777777: 126,
4444444: 127,
4444447: 128,
4444474: 129,
4444477: 130,
4444744: 131,
4444747: 132,
4444774: 133,
4444777: 134,
4447444: 135,
4447447: 136,
4447474: 137,
4447477: 138,
4447744: 139,
4447747: 140,
4447774: 141,
4447777: 142,
4474444: 143,
4474447: 144,
4474474: 145,
4474477: 146,
4474744: 147,
4474747: 148,
4474774: 149,
4474777: 150,
4477444: 151,
4477447: 152,
4477474: 153,
4477477: 154,
4477744: 155,
4477747: 156,
4477774: 157,
4477777: 158,
4744444: 159,
4744447: 160,
4744474: 161,
4744477: 162,
4744744: 163,
4744747: 164,
4744774: 165,
4744777: 166,
4747444: 167,
4747447: 168,
4747474: 169,
4747477: 170,
4747744: 171,
4747747: 172,
4747774: 173,
4747777: 174,
4774444: 175,
4774447: 176,
4774474: 177,
4774477: 178,
4774744: 179,
4774747: 180,
4774774: 181,
4774777: 182,
4777444: 183,
4777447: 184,
4777474: 185,
4777477: 186,
4777744: 187,
4777747: 188,
4777774: 189,
4777777: 190,
7444444: 191,
7444447: 192,
7444474: 193,
7444477: 194,
7444744: 195,
7444747: 196,
7444774: 197,
7444777: 198,
7447444: 199,
7447447: 200,
7447474: 201,
7447477: 202,
7447744: 203,
7447747: 204,
7447774: 205,
7447777: 206,
7474444: 207,
7474447: 208,
7474474: 209,
7474477: 210,
7474744: 211,
7474747: 212,
7474774: 213,
7474777: 214,
7477444: 215,
7477447: 216,
7477474: 217,
7477477: 218,
7477744: 219,
7477747: 220,
7477774: 221,
7477777: 222,
7744444: 223,
7744447: 224,
7744474: 225,
7744477: 226,
7744744: 227,
7744747: 228,
7744774: 229,
7744777: 230,
7747444: 231,
7747447: 232,
7747474: 233,
7747477: 234,
7747744: 235,
7747747: 236,
7747774: 237,
7747777: 238,
7774444: 239,
7774447: 240,
7774474: 241,
7774477: 242,
7774744: 243,
7774747: 244,
7774774: 245,
7774777: 246,
7777444: 247,
7777447: 248,
7777474: 249,
7777477: 250,
7777744: 251,
7777747: 252,
7777774: 253,
7777777: 254,
44444444: 255,
44444447: 256,
44444474: 257,
44444477: 258,
44444744: 259,
44444747: 260,
44444774: 261,
44444777: 262,
44447444: 263,
44447447: 264,
44447474: 265,
44447477: 266,
44447744: 267,
44447747: 268,
44447774: 269,
44447777: 270,
44474444: 271,
44474447: 272,
44474474: 273,
44474477: 274,
44474744: 275,
44474747: 276,
44474774: 277,
44474777: 278,
44477444: 279,
44477447: 280,
44477474: 281,
44477477: 282,
44477744: 283,
44477747: 284,
44477774: 285,
44477777: 286,
44744444: 287,
44744447: 288,
44744474: 289,
44744477: 290,
44744744: 291,
44744747: 292,
44744774: 293,
44744777: 294,
44747444: 295,
44747447: 296,
44747474: 297,
44747477: 298,
44747744: 299,
44747747: 300,
44747774: 301,
44747777: 302,
44774444: 303,
44774447: 304,
44774474: 305,
44774477: 306,
44774744: 307,
44774747: 308,
44774774: 309,
44774777: 310,
44777444: 311,
44777447: 312,
44777474: 313,
44777477: 314,
44777744: 315,
44777747: 316,
44777774: 317,
44777777: 318,
47444444: 319,
47444447: 320,
47444474: 321,
47444477: 322,
47444744: 323,
47444747: 324,
47444774: 325,
47444777: 326,
47447444: 327,
47447447: 328,
47447474: 329,
47447477: 330,
47447744: 331,
47447747: 332,
47447774: 333,
47447777: 334,
47474444: 335,
47474447: 336,
47474474: 337,
47474477: 338,
47474744: 339,
47474747: 340,
47474774: 341,
47474777: 342,
47477444: 343,
47477447: 344,
47477474: 345,
47477477: 346,
47477744: 347,
47477747: 348,
47477774: 349,
47477777: 350,
47744444: 351,
47744447: 352,
47744474: 353,
47744477: 354,
47744744: 355,
47744747: 356,
47744774: 357,
47744777: 358,
47747444: 359,
47747447: 360,
47747474: 361,
47747477: 362,
47747744: 363,
47747747: 364,
47747774: 365,
47747777: 366,
47774444: 367,
47774447: 368,
47774474: 369,
47774477: 370,
47774744: 371,
47774747: 372,
47774774: 373,
47774777: 374,
47777444: 375,
47777447: 376,
47777474: 377,
47777477: 378,
47777744: 379,
47777747: 380,
47777774: 381,
47777777: 382,
74444444: 383,
74444447: 384,
74444474: 385,
74444477: 386,
74444744: 387,
74444747: 388,
74444774: 389,
74444777: 390,
74447444: 391,
74447447: 392,
74447474: 393,
74447477: 394,
74447744: 395,
74447747: 396,
74447774: 397,
74447777: 398,
74474444: 399,
74474447: 400,
74474474: 401,
74474477: 402,
74474744: 403,
74474747: 404,
74474774: 405,
74474777: 406,
74477444: 407,
74477447: 408,
74477474: 409,
74477477: 410,
74477744: 411,
74477747: 412,
74477774: 413,
74477777: 414,
74744444: 415,
74744447: 416,
74744474: 417,
74744477: 418,
74744744: 419,
74744747: 420,
74744774: 421,
74744777: 422,
74747444: 423,
74747447: 424,
74747474: 425,
74747477: 426,
74747744: 427,
74747747: 428,
74747774: 429,
74747777: 430,
74774444: 431,
74774447: 432,
74774474: 433,
74774477: 434,
74774744: 435,
74774747: 436,
74774774: 437,
74774777: 438,
74777444: 439,
74777447: 440,
74777474: 441,
74777477: 442,
74777744: 443,
74777747: 444,
74777774: 445,
74777777: 446,
77444444: 447,
77444447: 448,
77444474: 449,
77444477: 450,
77444744: 451,
77444747: 452,
77444774: 453,
77444777: 454,
77447444: 455,
77447447: 456,
77447474: 457,
77447477: 458,
77447744: 459,
77447747: 460,
77447774: 461,
77447777: 462,
77474444: 463,
77474447: 464,
77474474: 465,
77474477: 466,
77474744: 467,
77474747: 468,
77474774: 469,
77474777: 470,
77477444: 471,
77477447: 472,
77477474: 473,
77477477: 474,
77477744: 475,
77477747: 476,
77477774: 477,
77477777: 478,
77744444: 479,
77744447: 480,
77744474: 481,
77744477: 482,
77744744: 483,
77744747: 484,
77744774: 485,
77744777: 486,
77747444: 487,
77747447: 488,
77747474: 489,
77747477: 490,
77747744: 491,
77747747: 492,
77747774: 493,
77747777: 494,
77774444: 495,
77774447: 496,
77774474: 497,
77774477: 498,
77774744: 499,
77774747: 500,
77774774: 501,
77774777: 502,
77777444: 503,
77777447: 504,
77777474: 505,
77777477: 506,
77777744: 507,
77777747: 508,
77777774: 509,
77777777: 510,
444444444: 511,
444444447: 512,
444444474: 513,
444444477: 514,
444444744: 515,
444444747: 516,
444444774: 517,
444444777: 518,
444447444: 519,
444447447: 520,
444447474: 521,
444447477: 522,
444447744: 523,
444447747: 524,
444447774: 525,
444447777: 526,
444474444: 527,
444474447: 528,
444474474: 529,
444474477: 530,
444474744: 531,
444474747: 532,
444474774: 533,
444474777: 534,
444477444: 535,
444477447: 536,
444477474: 537,
444477477: 538,
444477744: 539,
444477747: 540,
444477774: 541,
444477777: 542,
444744444: 543,
444744447: 544,
444744474: 545,
444744477: 546,
444744744: 547,
444744747: 548,
444744774: 549,
444744777: 550,
444747444: 551,
444747447: 552,
444747474: 553,
444747477: 554,
444747744: 555,
444747747: 556,
444747774: 557,
444747777: 558,
444774444: 559,
444774447: 560,
444774474: 561,
444774477: 562,
444774744: 563,
444774747: 564,
444774774: 565,
444774777: 566,
444777444: 567,
444777447: 568,
444777474: 569,
444777477: 570,
444777744: 571,
444777747: 572,
444777774: 573,
444777777: 574,
447444444: 575,
447444447: 576,
447444474: 577,
447444477: 578,
447444744: 579,
447444747: 580,
447444774: 581,
447444777: 582,
447447444: 583,
447447447: 584,
447447474: 585,
447447477: 586,
447447744: 587,
447447747: 588,
447447774: 589,
447447777: 590,
447474444: 591,
447474447: 592,
447474474: 593,
447474477: 594,
447474744: 595,
447474747: 596,
447474774: 597,
447474777: 598,
447477444: 599,
447477447: 600,
447477474: 601,
447477477: 602,
447477744: 603,
447477747: 604,
447477774: 605,
447477777: 606,
447744444: 607,
447744447: 608,
447744474: 609,
447744477: 610,
447744744: 611,
447744747: 612,
447744774: 613,
447744777: 614,
447747444: 615,
447747447: 616,
447747474: 617,
447747477: 618,
447747744: 619,
447747747: 620,
447747774: 621,
447747777: 622,
447774444: 623,
447774447: 624,
447774474: 625,
447774477: 626,
447774744: 627,
447774747: 628,
447774774: 629,
447774777: 630,
447777444: 631,
447777447: 632,
447777474: 633,
447777477: 634,
447777744: 635,
447777747: 636,
447777774: 637,
447777777: 638,
474444444: 639,
474444447: 640,
474444474: 641,
474444477: 642,
474444744: 643,
474444747: 644,
474444774: 645,
474444777: 646,
474447444: 647,
474447447: 648,
474447474: 649,
474447477: 650,
474447744: 651,
474447747: 652,
474447774: 653,
474447777: 654,
474474444: 655,
474474447: 656,
474474474: 657,
474474477: 658,
474474744: 659,
474474747: 660,
474474774: 661,
474474777: 662,
474477444: 663,
474477447: 664,
474477474: 665,
474477477: 666,
474477744: 667,
474477747: 668,
474477774: 669,
474477777: 670,
474744444: 671,
474744447: 672,
474744474: 673,
474744477: 674,
474744744: 675,
474744747: 676,
474744774: 677,
474744777: 678,
474747444: 679,
474747447: 680,
474747474: 681,
474747477: 682,
474747744: 683,
474747747: 684,
474747774: 685,
474747777: 686,
474774444: 687,
474774447: 688,
474774474: 689,
474774477: 690,
474774744: 691,
474774747: 692,
474774774: 693,
474774777: 694,
474777444: 695,
474777447: 696,
474777474: 697,
474777477: 698,
474777744: 699,
474777747: 700,
474777774: 701,
474777777: 702,
477444444: 703,
477444447: 704,
477444474: 705,
477444477: 706,
477444744: 707,
477444747: 708,
477444774: 709,
477444777: 710,
477447444: 711,
477447447: 712,
477447474: 713,
477447477: 714,
477447744: 715,
477447747: 716,
477447774: 717,
477447777: 718,
477474444: 719,
477474447: 720,
477474474: 721,
477474477: 722,
477474744: 723,
477474747: 724,
477474774: 725,
477474777: 726,
477477444: 727,
477477447: 728,
477477474: 729,
477477477: 730,
477477744: 731,
477477747: 732,
477477774: 733,
477477777: 734,
477744444: 735,
477744447: 736,
477744474: 737,
477744477: 738,
477744744: 739,
477744747: 740,
477744774: 741,
477744777: 742,
477747444: 743,
477747447: 744,
477747474: 745,
477747477: 746,
477747744: 747,
477747747: 748,
477747774: 749,
477747777: 750,
477774444: 751,
477774447: 752,
477774474: 753,
477774477: 754,
477774744: 755,
477774747: 756,
477774774: 757,
477774777: 758,
477777444: 759,
477777447: 760,
477777474: 761,
477777477: 762,
477777744: 763,
477777747: 764,
477777774: 765,
477777777: 766,
744444444: 767,
744444447: 768,
744444474: 769,
744444477: 770,
744444744: 771,
744444747: 772,
744444774: 773,
744444777: 774,
744447444: 775,
744447447: 776,
744447474: 777,
744447477: 778,
744447744: 779,
744447747: 780,
744447774: 781,
744447777: 782,
744474444: 783,
744474447: 784,
744474474: 785,
744474477: 786,
744474744: 787,
744474747: 788,
744474774: 789,
744474777: 790,
744477444: 791,
744477447: 792,
744477474: 793,
744477477: 794,
744477744: 795,
744477747: 796,
744477774: 797,
744477777: 798,
744744444: 799,
744744447: 800,
744744474: 801,
744744477: 802,
744744744: 803,
744744747: 804,
744744774: 805,
744744777: 806,
744747444: 807,
744747447: 808,
744747474: 809,
744747477: 810,
744747744: 811,
744747747: 812,
744747774: 813,
744747777: 814,
744774444: 815,
744774447: 816,
744774474: 817,
744774477: 818,
744774744: 819,
744774747: 820,
744774774: 821,
744774777: 822,
744777444: 823,
744777447: 824,
744777474: 825,
744777477: 826,
744777744: 827,
744777747: 828,
744777774: 829,
744777777: 830,
747444444: 831,
747444447: 832,
747444474: 833,
747444477: 834,
747444744: 835,
747444747: 836,
747444774: 837,
747444777: 838,
747447444: 839,
747447447: 840,
747447474: 841,
747447477: 842,
747447744: 843,
747447747: 844,
747447774: 845,
747447777: 846,
747474444: 847,
747474447: 848,
747474474: 849,
747474477: 850,
747474744: 851,
747474747: 852,
747474774: 853,
747474777: 854,
747477444: 855,
747477447: 856,
747477474: 857,
747477477: 858,
747477744: 859,
747477747: 860,
747477774: 861,
747477777: 862,
747744444: 863,
747744447: 864,
747744474: 865,
747744477: 866,
747744744: 867,
747744747: 868,
747744774: 869,
747744777: 870,
747747444: 871,
747747447: 872,
747747474: 873,
747747477: 874,
747747744: 875,
747747747: 876,
747747774: 877,
747747777: 878,
747774444: 879,
747774447: 880,
747774474: 881,
747774477: 882,
747774744: 883,
747774747: 884,
747774774: 885,
747774777: 886,
747777444: 887,
747777447: 888,
747777474: 889,
747777477: 890,
747777744: 891,
747777747: 892,
747777774: 893,
747777777: 894,
774444444: 895,
774444447: 896,
774444474: 897,
774444477: 898,
774444744: 899,
774444747: 900,
774444774: 901,
774444777: 902,
774447444: 903,
774447447: 904,
774447474: 905,
774447477: 906,
774447744: 907,
774447747: 908,
774447774: 909,
774447777: 910,
774474444: 911,
774474447: 912,
774474474: 913,
774474477: 914,
774474744: 915,
774474747: 916,
774474774: 917,
774474777: 918,
774477444: 919,
774477447: 920,
774477474: 921,
774477477: 922,
774477744: 923,
774477747: 924,
774477774: 925,
774477777: 926,
774744444: 927,
774744447: 928,
774744474: 929,
774744477: 930,
774744744: 931,
774744747: 932,
774744774: 933,
774744777: 934,
774747444: 935,
774747447: 936,
774747474: 937,
774747477: 938,
774747744: 939,
774747747: 940,
774747774: 941,
774747777: 942,
774774444: 943,
774774447: 944,
774774474: 945,
774774477: 946,
774774744: 947,
774774747: 948,
774774774: 949,
774774777: 950,
774777444: 951,
774777447: 952,
774777474: 953,
774777477: 954,
774777744: 955,
774777747: 956,
774777774: 957,
774777777: 958,
777444444: 959,
777444447: 960,
777444474: 961,
777444477: 962,
777444744: 963,
777444747: 964,
777444774: 965,
777444777: 966,
777447444: 967,
777447447: 968,
777447474: 969,
777447477: 970,
777447744: 971,
777447747: 972,
777447774: 973,
777447777: 974,
777474444: 975,
777474447: 976,
777474474: 977,
777474477: 978,
777474744: 979,
777474747: 980,
777474774: 981,
777474777: 982,
777477444: 983,
777477447: 984,
777477474: 985,
777477477: 986,
777477744: 987,
777477747: 988,
777477774: 989,
777477777: 990,
777744444: 991,
777744447: 992,
777744474: 993,
777744477: 994,
777744744: 995,
777744747: 996,
777744774: 997,
777744777: 998,
777747444: 999,
777747447: 1000,
777747474: 1001,
777747477: 1002,
777747744: 1003,
777747747: 1004,
777747774: 1005,
777747777: 1006,
777774444: 1007,
777774447: 1008,
777774474: 1009,
777774477: 1010,
777774744: 1011,
777774747: 1012,
777774774: 1013,
777774777: 1014,
777777444: 1015,
777777447: 1016,
777777474: 1017,
777777477: 1018,
777777744: 1019,
777777747: 1020,
777777774: 1021,
777777777: 1022
}


n = int(input())
print(d[n])



s = input().strip().replace("7", "1").replace("4", "0")
m = 0
for i in range(1, len(s)):

    m += 2 ** i

print(int(s, 2) + m + 1)


number = str(input())
ret = 0

def dothat(number, poww):
	yep = number
	for i in range(poww-1):
		number *= yep
	if poww == 0:
		number = 1
	return number

for i in range(len(number)):
	if number[i] == '4':
		ret += dothat(2, len(number) - i - 1)
	else:
		ret += dothat(2, len(number) - i)




print(ret)


s=input()
r=1 if s[0]=='4' else 2
for c in s[1:]:
    if  c=='4':
        r=r*2+1
    else:
        r=r*2+2
print(r)

def app(s, alph):
    nonlocal cnt
    alph[s] = cnt
    cnt += 1
def f(s, n, step, alph, used):
    if n == step:
        app(s, alph)
    else:
        if not used[step][0]:
            used[step][0] = True
            f(s + '4', n, step + 1, alph, used)
        if not used[step][1]:
            used[step][1] = True
            f(s + '7', n, step + 1, alph, used)
        used[step][0] = False
        used[step][1] = False
    return
def main():
    nonlocal cnt
    s = input()
    alph = dict()
    string = ''
    for i in range(10):
        used = [[False, False] for i in range(i + 1)]
        f('', i + 1, 0, alph, used)
    print(alph[s])
cnt = 1
main()

j = int(input())
s = [7, 4]
s1 = s
for i in range(11):
    ns = [i * 10 + 4 for i in s1] + [i * 10 + 7 for i in s1]
    s += ns
    s1 = ns

print(sorted(s).index(j) + 1)


n = int(input())
s = str(n)
l = len(s)
maxpos = 0
for i in range(1,l+1):
    maxpos += 2**i
pos = maxpos

s = s[::-1]
for i,c in enumerate(s):
    if c in "4":
        pos -= 2**i
print(pos)

s = str(input())
l = ""
for i in s:
    if i == "4":
        l+= "0"
    else:
        l+= "1"

sum = 0
for i in range(0, len(s)):
    sum+= 2**i


sum+=int(l, 2)

print(sum)

#!/usr/bin/env python
# -.- coding: utf-8 -.-

lucky = int(input())
lucky = str(lucky)
lenlucky = len(lucky)
acc = 0
acc += 2**(lenlucky) - 1
numindex = [4, 7]
for i in range(lenlucky):
    acc += numindex.index(int(lucky[i])) * 2**(lenlucky - i - 1)
print(acc)


n = int(input())
a = ""
while n!= 0:
    if n%10==4:
        a = "0" + a
    elif n%10==7:
        a = "1" + a
    n = n//10

a = "1" + a
m = int(a,2)
m = m-1
print(m)