#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int main() {
  int hh, mm;
  int ans = 0;
  scanf("%d:%d", &hh, &mm);
  for (int i = 0;; i++) {
    int up = (i + mm) / 60;
    int extra = (i + mm) % 60;
    int h = (up + hh) % 24;
    if (extra < 10)
      extra = extra * 10;
    else {
      extra = (extra % 10) * 10 + (extra / 10);
    }
    if (extra == h) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
