#include <bits/stdc++.h>
using namespace std;
char s1[10], s2[10];
int giay;
char s[20];
int kiemtra() {
  int gio, phut;
  gio = giay / 60;
  phut = giay % 60;
  if (gio == 24) gio = 0;
  s[4] = '\0';
  s[3] = (phut % 10) + '0';
  s[2] = (phut / 10) + '0';
  s[1] = (gio % 10) + '0';
  s[0] = (gio / 10) + '0';
  if (s[0] != s[3] || s[1] != s[2]) return 0;
  return 1;
}
int main() {
  int kq, k1, k2;
  while (scanf("%s", &s) > 0) {
    s1[0] = s[0];
    s1[1] = s[1];
    s2[0] = s[3];
    s2[1] = s[4];
    kq = 0;
    k1 = (s1[0] - '0') * 10 + (s1[1] - '0');
    k2 = (s2[0] - '0') * 10 + (s2[1] - '0');
    giay = k2 + k1 * 60;
    while (true) {
      if (kiemtra() == 1) break;
      giay++;
      kq++;
    }
    printf("%d\n", kq);
  }
  return 0;
}
