Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long int ull;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef pair<int,int> pii;
- typedef vector< pii > vpii;
- typedef set<int> sti;
- #define pb push_back
- #define pob pop_back
- #define mp make_pair
- #define ff first
- #define ss second
- #define loop1(i,n) for(int i=1; i<=int(n); i++)
- #define loop(i,y) for(int i=0; i<int(y); i++)
- #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- #define cspf(i) printf("Case %d: ", i)
- /// Constants
- #define eps 1e-9
- #define PI acos(-1.0) // 3.1415926535897932
- char s[500009];
- int main()
- {
- scanf("%s",s);
- int i,ln,sz=0,sb=0,eb=0,fb=0,lb=0;
- ln=strlen(s);
- for(i=0;i<ln;i++){
- if(fb==0){
- if(s[i]=='['){
- sb=i;
- fb++;
- }
- }
- if(s[i]==']'){
- eb=i;
- lb++;
- }
- }
- if(sb+3>eb || fb==0 || lb==0){
- cout<<"-1"<<endl;
- return 0;
- }
- sz+=2;
- int c1=0,c2=0,fc=0,lc=0;
- for(i=sb+1;i<eb;i++){
- if(fc==0){
- if(s[i]==':'){
- c1=i;
- fc++;
- continue;
- }
- }
- if(s[i]==':'){
- c2=i;
- lc++;
- }
- }
- if(c1+1>c2 || fc==0 || lc==0){
- cout<<"-1"<<endl;
- return 0;
- }
- sz+=2;
- for(i=c1+1;i<c2;i++){
- if(s[i]=='|')
- sz++;
- }
- cout<<sz<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement