





from dataclasses import dataclass
from typing import Optional, Tuple, Union

import numpy as np
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, randn_tensor
from .scheduling_utils import SchedulerMixin
@dataclass
class     UpperCamelCase__					(     lowerCamelCase__				):






		'''simple docstring'''






		__a       :       torch.FloatTensor
		__a       :       torch.FloatTensor
		__a       :       Optional[torch.FloatTensor]       =	None




class     UpperCamelCase__					(     lowerCamelCase__				, lowerCamelCase__				):






		'''simple docstring'''






		__a       :       List[str]       =	2






		@register_to_config
		def __init__(							self,   snake_case__ = 0.02,   snake_case__ = 1_00,   snake_case__ = 1.007,   snake_case__ = 80,   snake_case__ = 0.05,   snake_case__ = 50,   )       -> Any:






									"""simple docstring"""
									# standard deviation of the initial noise distribution
									lowercase_	:   int  				=     sigma_max

									# setable values
									lowercase_	:   int  				=     None
									lowercase_	:   np.IntTensor  				=     None
									lowercase_	:   torch.FloatTensor  				=     None  # sigma(t_i)






		def 						snake_case__				(							self,   snake_case__,   snake_case__ = None  )       -> torch.FloatTensor:






									"""simple docstring"""
									return sample






		def 						snake_case__				(							self,   snake_case__,   snake_case__ = None  )       -> Optional[Any]:






									"""simple docstring"""
									lowercase_	:   List[Any]  				=     num_inference_steps
									lowercase_	:   Optional[int]  				=     np.arange(0,   self.num_inference_steps  )[::-1].copy()
									lowercase_	:   Tuple  				=     torch.from_numpy(snake_case__  ).to(snake_case__  )
									lowercase_	:   Union[str, Any]  				=     [
									    (
									        self.config.sigma_max**2
									        * (self.config.sigma_min**2 / self.config.sigma_max**2) ** (i / (num_inference_steps - 1))
									    )
									    for i in self.timesteps
									]
									lowercase_	:   Tuple  				=     torch.tensor(snake_case__,   dtype=torch.floataa,   device=snake_case__  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__ = None  )       -> Tuple[torch.FloatTensor, float]:






									"""simple docstring"""
									if self.config.s_min <= sigma <= self.config.s_max:
																lowercase_	:   str  				=     min(self.config.s_churn / self.num_inference_steps,   2**0.5 - 1  )
									else:
																lowercase_	:   Dict  				=     0

									# sample eps ~ N(0, S_noise^2 * I)
									lowercase_	:   Union[str, Any]  				=     self.config.s_noise * randn_tensor(sample.shape,   generator=snake_case__  ).to(sample.device  )
									lowercase_	:   Any  				=     sigma + gamma * sigma
									lowercase_	:   Union[str, Any]  				=     sample + ((sigma_hat**2 - sigma**2) ** 0.5 * eps)

									return sample_hat, sigma_hat






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__ = True,   )       -> Union[KarrasVeOutput, Tuple]:






									"""simple docstring"""
									lowercase_	:   str  				=     sample_hat + sigma_hat * model_output
									lowercase_	:   List[Any]  				=     (sample_hat - pred_original_sample) / sigma_hat
									lowercase_	:   Optional[int]  				=     sample_hat + (sigma_prev - sigma_hat) * derivative

									if not return_dict:
																return (sample_prev, derivative)

									return KarrasVeOutput(
									    prev_sample=snake_case__,   derivative=snake_case__,   pred_original_sample=snake_case__  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__ = True,   )       -> Union[KarrasVeOutput, Tuple]:






									"""simple docstring"""
									lowercase_	:   Optional[Any]  				=     sample_prev + sigma_prev * model_output
									lowercase_	:   Union[str, Any]  				=     (sample_prev - pred_original_sample) / sigma_prev
									lowercase_	:   List[Any]  				=     sample_hat + (sigma_prev - sigma_hat) * (0.5 * derivative + 0.5 * derivative_corr)

									if not return_dict:
																return (sample_prev, derivative)

									return KarrasVeOutput(
									    prev_sample=snake_case__,   derivative=snake_case__,   pred_original_sample=snake_case__  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__  )       -> int:






									"""simple docstring"""
									raise NotImplementedError()






def  __magic_name__  (				lowercase = 1000				)				-> int:

							"""simple docstring"""



							lowercase_				,		lowercase_	:   Optional[Any]  				=     1, 1
							lowercase_	:   Tuple  				=     2
							while True:
														lowercase_	:   Dict  				=     0
														lowercase_	:   List[Any]  				=     fa + fa
														lowercase_				,		lowercase_	:   List[str]  				=     fa, f
														index += 1
														for _ in str(lowercase				):
																					i += 1
														if i == n:
																					break
							return index


if __name__ == "__main__":
							print(solution(int(str(input()).strip())))