\RequirePackage[utf8]{inputenc}
\RequirePackage[russian]{babel}
\RequirePackage[usenames]{color}
\RequirePackage{colortbl}
\RequirePackage{graphicx}
\RequirePackage{longtable}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{array}
\RequirePackage{extsizes}
\RequirePackage{xcolor}
\RequirePackage{tikz}
\RequirePackage{textcomp}
\RequirePackage{wrapfig}
\RequirePackage{multicol}
\RequirePackage{hyperref}
\RequirePackage{xstring}
\RequirePackage[nomessages]{fp}
\textwidth=160mm
\textheight=250mm
\oddsidemargin=5mm
\topmargin=-20mm
\pagestyle{empty}
\newtheorem{theorem}{\indent{\sc Теорема}}
\renewcommand{\thetheorem}{\rm \arabic{theorem}}
\newtheorem{lemm}{\indent{\sc Лемма}}
\renewcommand{\thelemm}{\rm \arabic{lemm}}
\newtheorem{corollary}{\indent{\sc Следствие}}
\renewcommand{\thecorollary}{\rm \arabic{corollary}}
\newtheorem{note}{\indent{\sc Замечание}}
\renewcommand{\thenote}{\rm \arabic{note}}
\renewcommand{\baselinestretch}{1,3}
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}.}
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}
\renewcommand{\section}{\@startsection{section}{1}{0pt}{3.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}{\normalfont\Large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0pt}{3.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}{\normalfont\large\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0pt}{3.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}{\normalfont\bfseries}}


\let\oldincludegraphics\includegraphics
\renewcommand*{\includegraphics}[1]{%
  \IfFileExists{#1}
  {%
    \oldincludegraphics{#1}%
  }
  {%  
    \StrLen{#1}[\length]%
    \StrCount{#1}{/}[\countSlash]%
    \StrPosition[\countSlash]{#1}{/}[\indexSlash]%
    \FPeval{filenameSize}{round(\length-\indexSlash,0)}%
    \filenameSize%
    \StrRight{#1}{\filenameSize}[\filename]%
    \IfFileExists{\filename}{}{\immediate\write18{curl \detokenize{#1} -o \filename}}%
    \oldincludegraphics{\filename}%
  }
}